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

From Gcube Wiki
Jump to: navigation, search
(Resource Registry Context Client)
 
(204 intermediate revisions by the same user not shown)
Line 5: Line 5:
 
|}
 
|}
  
This sections provide information regarding how to interact with [[Information System Resource Registry#Resource_Registry Service | Resource Registry Service]]. REST and JAVA API are presented for each functionality.
+
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.
Line 11: Line 12:
 
== 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;
* [[#Read|Read]]
+
* two contexts with the same name can only exist if they have different parents;
* [[#Rename|Rename]]
+
* any update to a context does not have any side effect on the instances belonging to the context;
* [[#Move|Move]]
+
* it is not possible to delete a context if
* [[#Delete|Delete]]
+
** 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>
  
=== Read ===
 
  
<pre>GET /resource-registry/context/{UUID}</pre>
+
==== List via REST API ====
  
==== Description ====
+
<pre>GET /resource-registry/contexts</pre>
  
Return the definition of the Context identified by the UUID provided as path parameter.
 
 
==== Parameters ====
 
 
{|class="wikitable"
 
! Name
 
! Type
 
! Required
 
! Description
 
|-
 
| '''{''Path Parameter''}'''
 
| String (UUID)
 
| true
 
| The UUID of the target context.
 
|}
 
 
==== Responses ====
 
  
 
{|class="wikitable"
 
{|class="wikitable"
Line 194: 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'''
  
Read the Context having UUID '''9d73d3bd-1873-490c-b0a7-e3c0da11ad52'''
+
<pre>GET /resource-registry/contexts</pre>
  
''Request URL''
+
'''Response Body'''
  
<pre>GET /resource-registry/context/9d73d3bd-1873-490c-b0a7-e3c0da11ad52</pre>
+
<source lang="JavaScript">
 
+
[
''Response Body''
+
{
 
+
"@class": "Context",
<pre>
+
"header": {
{
+
"@class": "Header",
"@class":"Context",
+
"uuid": "ca50eb95-b76c-44fd-9182-229d39c3c9e2",
"name":"devVRE",
+
"createdBy": "luca.frosini",
"header": {
+
"creationTime": "2021-06-30 09:38:26.464 +0000",
"@class":"Header",
+
"lastUpdateBy": "luca.frosini",
"uuid":"9d73d3bd-1873-490c-b0a7-e3c0da11ad52",
+
"lastUpdateTime": "2021-06-30 09:38:26.464 +0000"
"creator":"luca.frosini",
+
},
"lastUpdater":"luca.frosini",
+
"name": "gcube",
"creationTime":"2017-03-17 11:47:56",
+
"parent": null,
"lastUpdateTime":"2017-03-17 11:52:56"
+
"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": []
 
}
 
}
}
+
]
</pre>
+
</source>
  
=== Rename ===
+
=== Create Context ===
  
<pre>POST /resource-registry/context/rename/{UUID}</pre>
+
Create new Context as a child of another Context (if any).
  
==== Description ====
+
==== Create via Java Client ====
  
Rename a Context identified by the UUID provided as path parameter to the new name provided as query parameter.
+
===== Create via Java Client Example 1 =====
  
==== Parameters ====
+
This Java code snippet shows how to create a new Context with name '''gcube''' with no parent. It is a ROOT Context.
  
{|class="wikitable"
+
<source lang="java">
! Name
+
ResourceRegistryContextClient resourceRegistryContextClient = ResourceRegistryContextClientFactory.create();
! 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 ====
+
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 =====
! Code
+
! Type
+
! Description
+
|-
+
| 200
+
| String
+
| The json representation of the context.
+
|}
+
  
==== Examples ====
+
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).
  
Rename a Context '''9d73d3bd-1873-490c-b0a7-e3c0da11ad52''' (was '''devVRE''') to the new name '''devNext'''.
+
<source lang="java">
 +
ResourceRegistryContextClient resourceRegistryContextClient = ResourceRegistryContextClientFactory.create();
 +
Context gcubeContext = resourceRegistryContextClient.read("ca50eb95-b76c-44fd-9182-229d39c3c9e2");
  
''Request URL''
+
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);
 +
</source>
  
<pre>POST /resource-registry/context/rename/9d73d3bd-1873-490c-b0a7-e3c0da11ad52?name=devNext</pre>
+
==== Create via REST API ====
 
+
''Response Body''
+
 
+
<pre>
+
{
+
"@class":"Context",
+
"name":"devNext",
+
"header": {
+
"@class":"Header",
+
"uuid":"9d73d3bd-1873-490c-b0a7-e3c0da11ad52",
+
"creator":"luca.frosini",
+
"lastUpdater":"luca.frosini",
+
"creationTime":"2017-03-17 11:47:56",
+
"lastUpdateTime":"2017-03-17 11:52:56"
+
}
+
}
+
</pre>
+
 
+
=== Move ===
+
 
+
<pre>POST /resource-registry/context/move/{{UUID}}</pre>
+
 
+
==== Description ====
+
 
+
Move a Context identified by the UUID provided as path parameter as child of the Context provided as query parameter.
+
 
+
==== Parameters ====
+
 
+
{|class="wikitable"
+
! Name
+
! Type
+
! Required
+
! Description
+
|-
+
| '''{''Path Parameter''}'''
+
| String (UUID)
+
| true
+
| The UUID of the target Context
+
|-
+
| '''parentContextId'''
+
| String (UUID)
+
| true
+
| The parent Context UUID
+
|}
+
  
==== Responses ====
+
<pre>PUT /resource-registry/contexts/{{UUID}}</pre>
  
 
{|class="wikitable"
 
{|class="wikitable"
Line 322: 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]
+
  
{|class="wikitable"
+
<source lang="java">
! Type
+
ResourceRegistryContextClient resourceRegistryContextClient = ResourceRegistryContextClientFactory.create();
! Integer Mapping
+
UUID devNextUUID = UUID.fromString("aa860961-6eb0-4c1c-89fb-c406fe2a2771");
! Java type
+
Context devNextContext = resourceRegistryContextClient.read(devNextUUID);
! Description
+
</source>
|-
+
| Boolean
+
| 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
+
| 7
+
| <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.
+
|}
+
  
=== Type Creation ===
 
  
<pre>PUT /resource-registry/schema/{{type}} </pre>
+
Read using context instance. This normally used when we already have the context instance.
  
==== Description ====
+
<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>
  
Allow to create new Entity or Relation or Embedded Type.
 
  
==== Parameters ====
+
==== Read via REST API  ====
  
{|class="wikitable"
+
<pre>GET /resource-registry/context/{UUID}</pre>
! Name
+
! Type
+
! Required
+
! Description
+
|-
+
| '''type'''
+
| String
+
| true
+
| The name of the new type to create
+
|}
+
 
+
==== Responses ====
+
  
 
{|class="wikitable"
 
{|class="wikitable"
Line 535: Line 621:
 
| 200
 
| 200
 
| String
 
| String
| The json representation of the newly created type (which is the same of the request)
+
| The JSON representation of the requested Context
 
|}
 
|}
  
==== Examples ====
 
  
===== Resource Type Creation =====
+
===== Read via REST API Example 1 =====
  
<pre>PUT /resource-registry/schema/Actor</pre>
+
Read the Context having UUID '''ca50eb95-b76c-44fd-9182-229d39c3c9e2''' (gcube)
  
'''''Request Body'''''
+
'''Request URL'''
<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 =====
+
<pre>GET /resource-registry/contexts/ca50eb95-b76c-44fd-9182-229d39c3c9e2</pre>
  
<pre>PUT /resource-registry/schema/ContactFacet</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/Hosts
+
</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/HasContact
+
 
</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/AccessPolicy
+
</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>
+
  
 +
The possible updates are on:
 +
* name;
 +
* parent Context.
  
=== Read Type Definition ===
 
  
<pre>GET /resource-registry/schema/{{type}} </pre>
+
==== Update via Java Client ====
  
==== Description ====
+
<source lang="java">
 +
ResourceRegistryContextClient resourceRegistryContextClient = ResourceRegistryContextClientFactory.create();
  
Allow to read Type Definition
+
Context contextToBeUpdated = ....;
  
==== Parameters ====
+
Context updatedContext = resourceRegistryContextClient.update(contextToBeUpdated);
 +
</source>
  
{|class="wikitable"
+
==== Update via REST API ====
! Name
+
! Type
+
! Required
+
! Description
+
|-
+
| '''type'''
+
| String
+
| true
+
| The name of the type you want to retrieve the definition
+
|}
+
  
==== Responses ====
+
<pre>PUT /resource-registry/contexts/{UUID}</pre>
  
 
{|class="wikitable"
 
{|class="wikitable"
Line 701: Line 802:
 
| 200
 
| 200
 
| String
 
| String
| The json representation of the newly created type
+
| The JSON representation of the updated Context
 
|}
 
|}
  
==== Examples ====
+
==== Rename Context ====
  
===== Resource Type =====
+
===== Rename via Java Client =====
  
<pre>GET /resource-registry/schema/Actor</pre>
+
Rename a Context '''aa860961-6eb0-4c1c-89fb-c406fe2a2771''' (was '''devNext''') to the new name '''newDevNext'''.
  
'''''Response'''''
+
<source lang="java">
<pre>
+
ResourceRegistryContextClient resourceRegistryContextClient = ResourceRegistryContextClientFactory.create();
{
+
Context devNextContext = resourceRegistryContextClient.read("aa860961-6eb0-4c1c-89fb-c406fe2a2771");
"name":"Actor",
+
devNextContext.setName("newDevNext");
"description":"Any entity (human or machine) playing an active role.",
+
Context newDevNext = resourceRegistryContextClient.update(devNextContext);
"abstractType":true,
+
</source>
"superclasses":["Resource"],
+
"properties":null
+
}
+
</pre>
+
  
===== Facet Type =====
+
===== Rename via REST API =====
  
<pre>GET /resource-registry/schema/ContactFacet</pre>
+
Rename a Context '''aa860961-6eb0-4c1c-89fb-c406fe2a2771''' (was '''devNext''') to the new name '''newDevNext'''.
  
'''''Response'''''
+
'''Request URL'''
<pre>
+
{
+
"name":"ContactFacet",
+
"description":"This facet is expected to capture contact information",
+
"abstractType": false,
+
"superclasses":["Facet"],
+
"properties":[
+
{
+
"name":"name",
+
"description":"First Name",
+
"mandatory":true,
+
"readonly":false,
+
"notnull":true,
+
"max":null,
+
"min":null,
+
"regexpr":null,
+
"linkedType":null,
+
"linkedClass":null,
+
"type":7 /* String*/
+
},{
+
"name":"eMail",
+
"description": "A restricted range of RFC‑822 compliant email address. ... ",
+
"mandatory":true,
+
"readonly":false,
+
"notnull":true,
+
"max":null,
+
"min":null,
+
"regexpr":"^[a-z0-9._%+-]{1,128}@[a-z0-9.-]{1,128}$",
+
"linkedType":null,
+
"linkedClass":null,
+
"type":7 /* String */
+
}
+
]
+
}
+
</pre>
+
  
===== IsRelatedTo Type =====
+
<pre>PUT /resource-registry/contexts/aa860961-6eb0-4c1c-89fb-c406fe2a2771</pre>
<pre>GET /resource-registry/schema/Hosts</pre>
+
  
'''''Response'''''
+
'''Request Body'''
<pre>
+
{
+
"name":"Hosts",
+
"description": "…”,
+
"abstractType":false,
+
"superclasses":["IsRelatedTo"],
+
"properties":[]
+
}
+
</pre>
+
  
===== ConsistsOf Type =====
+
<source lang="javascript">
 
+
<pre>GET /resource-registry/schema/HasContact</pre>
+
 
+
'''''Response'''''
+
<pre>
+
 
{
 
{
"name":"HasContact",
+
    "@class": "Context",
"description":"",
+
    "header": {
"abstractType":true,
+
        "@class": "Header",
"superclasses":["ConsistsOf"],
+
        "uuid": "aa860961-6eb0-4c1c-89fb-c406fe2a2771"
"properties":[]
+
    },
 +
    "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>
  
===== Embedded Type =====
+
'''Response Body'''
<pre>GET /resource-registry/schema/AccessPolicy</pre>
+
  
'''''Response'''''
+
<source lang="javascript">
<pre>
+
 
{
 
{
"name":"AccessPolicy",
+
    "name": "newDevNext",
"description":"",
+
    "header": {
"abstractType":false,
+
        "@class": "Header",
"superclasses":["Embedded"],
+
        "creationTime": "2021-06-30 11:38:26.978 +0200",
"properties":[{
+
        "createdBy": "luca.frosini",
"name":"policy",
+
        "uuid": "aa860961-6eb0-4c1c-89fb-c406fe2a2771",
"description":"",
+
        "lastUpdateBy": "luca.frosini",
"mandatory":false,
+
        "lastUpdateTime": "2021-07-01 16:44:46.592 +0200"
"readonly":false,
+
    },
"notnull":false,
+
    "@class": "Context",
"max":null,
+
    "parent": {
"min":null,
+
        "header": {
"regexpr":null,
+
            "@class": "Header",
"linkedType":null,
+
            "creationTime": "2021-07-01 16:43:57.358 +0200",
"linkedClass":”ValueSchema”,
+
            "createdBy": "luca.frosini",
"type": 9  /* Embedded */
+
            "uuid": "c470a070-83e8-45e8-8630-440225702acc",
},{
+
            "lastUpdateBy": "luca.frosini",
"name":"note",
+
            "lastUpdateTime": "2021-07-01 16:43:57.358 +0200"
"description":"",
+
        },
"mandatory": false,
+
        "@class": "IsParentOf",
"readonly":false,
+
        "source": {
"notnull":false,
+
            "name": "gcube",
"max":null,
+
            "header": {
"min":null,
+
                "@class": "Header",
"regexpr":null,
+
                "creationTime": "2021-06-30 11:38:26.464 +0200",
"linkedType":null,
+
                "createdBy": "luca.frosini",
"linkedClass":null,
+
                "uuid": "ca50eb95-b76c-44fd-9182-229d39c3c9e2",
"type":7 /* String */
+
                "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>
  
== ER Management ==
+
==== Move 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.
+
We have 5 Contexts organized in the following Context Tree:
 
+
 
+
[[Information System Resource Registry#Resource_Registry_Publisher | Resource Registry Publisher]] has the following maven coordinates
+
  
 
<pre>
 
<pre>
<dependency>
+
-  ca50eb95-b76c-44fd-9182-229d39c3c9e2 (gcube)
<groupId>org.gcube.information-system</groupId>
+
|
<artifactId>resource-registry-publisher</artifactId>
+
|---- d0544ff9-8f61-416f-b685-589a2262e2c4 (devsec)
<version>[1.0.0-SNAPSHOT, 2.0.0-SNAPSHOT)</version>
+
|  |
</dependency>
+
|  |---- 4c0c3500-32d6-11ea-867c-af3c989f8e41 (devVRE)
 +
|
 +
|---- aa860961-6eb0-4c1c-89fb-c406fe2a2771 (devNext)
 +
    |
 +
    |---- bad5f350-345c-11e9-9f49-cef9b1608c3f (NextNext)
 
</pre>
 
</pre>
  
To use the client you need first get a ''ResourceRegistryPublisher'' instance.
+
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)
By using ResourceRegistryPublisher.create() method the library discover the correct endpoint to interact with the Resource Registry for the current context.
+
In other words, NextNext will be a VO in place of a VRE.
  
<pre>
+
We will obtain the following Context tree
SecurityTokenProvider.instance.set("Your-NextNext-Token-Here"); //If not already set
+
ResourceRegistryPublisher resourceRegistryPublisher = ResourceRegistryPublisherFactory.create();
+
</pre>
+
 
+
 
+
=== Facet Instances APIs ===
+
 
+
==== Create Facet Instance ====
+
  
===== REST API =====
 
 
<pre>
 
<pre>
PUT /resource-registry/er/facet/CPUFacet
+
- 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>
  
'''''Request Body'''''
 
<pre>
 
{
 
"@class":"CPUFacet",
 
"header":null,
 
"model":"Opteron",
 
"vendor":"AMD",
 
"clockSpeed":"1 GHz"
 
}
 
</pre>
 
  
'''''Response Body'''''
+
===== Move with Java client =====
<pre>
+
{
+
"@class":"CPUFacet",
+
"header": {
+
"uuid":"69f0b376-38d2-4a85-bc63-37f9fa323f82",
+
"creator":"luca.frosini",
+
"lastUpdater":"luca.frosini",
+
"creationTime":"2016-10-05 11:16:24",
+
"lastUpdateTime":"2016-10-05 11:16:24
+
},
+
"model":"Opteron",
+
"vendor":"AMD",
+
"clockSpeed":"1 GHz"
+
}
+
</pre>
+
  
===== Java API =====
+
<source lang="java">
 +
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);
 +
</source>
  
<pre>
 
public <F extends Facet> F createFacet(F facet) throws FacetAlreadyPresentException, ResourceRegistryException;
 
</pre>
 
  
====== Example ======
+
===== Move via REST API =====
<pre>
+
CPUFacet cpuFacet = new CPUFacetImpl();
+
cpuFacet.setClockSpeed("1 GHz");
+
cpuFacet.setModel("Opteron");
+
cpuFacet.setVendor("AMD");
+
  
CPUFacet createdCpuFacet = resourceRegistryPublisher.createFacet(cpuFacet);
+
If we read the Context ''bad5f350-345c-11e9-9f49-cef9b1608c3f''' (NextNext) before moving it we have:
UUID uuid = createdCpuFacet.getHeader().getUUID(); // 69f0b376-38d2-4a85-bc63-37f9fa323f82
+
</pre>
+
  
 
+
<source lang="javascript">
There are also two other equivalent methods with the following signature:
+
 
+
<pre>
+
public String createFacet(String facet) throws FacetAlreadyPresentException, ResourceRegistryException;
+
 
+
public String createFacet(String facetType, String facet) throws FacetAlreadyPresentException, ResourceRegistryException;
+
</pre>
+
 
+
The first methods get the Facet to be created as JSON string instead of as Java class.
+
The second get also the '''facetType''' as parameter (which as to be specified as PATH PARAMETER in the request) avoiding to force client to retrieve it from the string.
+
The second method is more efficient but you have to be sure that the '''facetType''' is the same specified in the header of the serialized facet.
+
 
+
==== Update Facet Instance ====
+
 
+
===== REST API =====
+
<pre>
+
POST /resource-registry/er/facet/69f0b376-38d2-4a85-bc63-37f9fa323f82
+
</pre>
+
 
+
'''''Request Body'''''
+
<pre>
+
 
{
 
{
"@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": "bad5f350-345c-11e9-9f49-cef9b1608c3f",
"clockSpeed":"2 GHz"
+
        "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": []
 
}
 
}
</pre>
+
</source>
  
'''''Response Body'''''
+
'''Request URL'''
<pre>
+
{
+
"@class":"CPUFacet",
+
"header": {
+
"uuid":"69f0b376-38d2-4a85-bc63-37f9fa323f82",
+
"creator":"luca.frosini",
+
"lastUpdater":"luca.frosini",
+
"creationTime":"2016-10-05 11:16:24",
+
"lastUpdateTime":"2016-10-05 11:17:32"
+
},
+
"model":"Opteron",
+
"vendor":"AMD",
+
"clockSpeed":"2 GHz"
+
}
+
</pre>
+
  
===== Java API =====
+
<pre>PUT /resource-registry/contexts/bad5f350-345c-11e9-9f49-cef9b1608c3f</pre>
  
<pre>
+
'''Request Body'''
public <F extends Facet> F updateFacet(F facet) throws FacetNotFoundException, ResourceRegistryException;
+
</pre>
+
  
====== Example ======
+
<source lang="javascript">
 
+
<pre>
+
createdCpuFacet.setClockSpeed("2 GHz");
+
CPUFacet updatedCpuFacet = resourceRegistryPublisher.updateFacet(createdCpuFacet);
+
</pre>
+
 
+
There are also two other equivalent methods with the following signature:
+
 
+
<pre>
+
public String updateFacet(String facet) throws FacetNotFoundException, ResourceRegistryException;
+
public String updateFacet(UUID uuid, String facet) throws FacetNotFoundException, ResourceRegistryException;
+
</pre>
+
 
+
The first methods get the Facet to be created as JSON string instead of as Java class.
+
The second get also the '''uuid''' as parameter (which as to be specified as PATH PARAMETER in the request) avoiding to force client to retrieve it from the string.
+
The second method is more efficient but you have to be sure that the provided '''uuid''' is the same specified in the header of the serialized facet.
+
 
+
==== Delete Facet Instance ====
+
 
+
===== REST API =====
+
<pre>
+
DELETE /resource-registry/er/facet/69f0b376-38d2-4a85-bc63-37f9fa323f82
+
</pre>
+
 
+
'''''Response Body'''''
+
<pre>
+
true
+
</pre>
+
 
+
===== Java API =====
+
 
+
<pre>
+
public <F extends Facet> boolean deleteFacet(F facet) throws FacetNotFoundException, ResourceRegistryException;
+
</pre>
+
 
+
====== Example ======
+
 
+
<pre>
+
boolean deleted = resourceRegistryPublisher.deleteFacet(createdCpuFacet);
+
</pre>
+
 
+
There is also another equivalent methods with the following signature:
+
 
+
<pre>
+
public boolean deleteFacet(UUID uuid) throws FacetNotFoundException, ResourceRegistryException;
+
</pre>
+
 
+
The method just need the UUID of the Facet to be deleted.
+
 
+
=== Resource Instances APIs ===
+
 
+
==== Create Resource Instance ====
+
 
+
===== REST API =====
+
<pre>
+
PUT /resource-registry/er/resource/HostingNode
+
</pre>
+
 
+
'''''Request Body'''''
+
<pre>
+
 
{
 
{
"@class":"HostingNode",
+
    "@class": "Context",
"consistsOf":[
+
    "header": {
{  
+
        "@class": "Header",
"@class":"ConsistsOf",  
+
        "uuid": "bad5f350-345c-11e9-9f49-cef9b1608c3f",
"target":{
+
    },
"@class":"CPUFacet",
+
    "name": "NextNext",
"model":"Opteron",
+
    "parent": {
"vendor":"AMD",
+
        "header": {
"clockSpeed":"3 GHz"
+
            "@class": "Header",
}
+
            "uuid": "c470a070-83e8-45e8-8630-440225702acc"
},{
+
        },
"@class":"IsIdentifiedBy",
+
        "@class": "IsParentOf"
"target":{  
+
        "source": {
"@class":"NetworkingFacet",
+
            "name": "gcube",
"header":{"uuid":"59617b01-5856-4d8e-b85c-590a42039933"},
+
            "header": {
/* In this example we suppose that the NetworkingFacet was already created, so the UUID is enought to attach it by using IsIdentifiedBy relation */
+
                "@class": "Header",
}
+
                "uuid": "ca50eb95-b76c-44fd-9182-229d39c3c9e2"
}
+
            },
],
+
            "@class": "Context"
"isRelatedTo":[
+
        }
{
+
    },
"@class":"Hosts",
+
    "children": []
"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 */
+
}
+
}
+
]
+
 
}
 
}
 +
</source>
  
</pre>
+
'''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",
}
+
                "creationTime": "2021-06-30 11:38:26.464 +0200",
}
+
                "createdBy": "luca.frosini",
],
+
                "uuid": "ca50eb95-b76c-44fd-9182-229d39c3c9e2",
"isRelatedTo":[
+
                "lastUpdateBy": "luca.frosini",
{
+
                "lastUpdateTime": "2021-06-30 11:38:26.464 +0200"
"@class":"Hosts",
+
            },
"header":{"uuid":"47494ad0-e606-4630-9def-4c607761ae14", ...},
+
            "@class": "Context"
"propagationConstraint":{
+
        }
"add":"unpropagate",
+
    }
"remove": "cascade"
+
},
+
"target":{
+
"@class":"EService",
+
"header":{"uuid":"9bff49c8-c0a7-45de-827c-accb71defbd3", ...}
+
}
+
}
+
]
+
 
}
 
}
</pre>
+
</source>
  
===== Java API =====
+
=== Delete Context ===
  
<pre>
 
public <R extends Resource> R createResource(R resource) throws ResourceAlreadyPresentException, ResourceRegistryException;
 
</pre>
 
  
====== Example ======
+
Delete the Context identified by the UUID provided as the path parameter.
  
<pre>
+
'''The resource registry performs the following checks before deleting a context:'''
NetworkingFacet networkingFacet = new NetworkingFacetImpl();
+
* '''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'';'''
networkingFacet.setIPAddress("146.48.87.183");
+
* '''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.'''
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);
+
==== Delete via Java Client ====
  
HostingNode hostingNode = new HostingNodeImpl();
+
Delete using UUID. This normally used when we already have the UUID instance.
  
CPUFacet cpuFacet = new CPUFacetImpl();
+
<source lang="java">
cpuFacet.setClockSpeed("1 GHz");
+
ResourceRegistryContextClient resourceRegistryContextClient = ResourceRegistryContextClientFactory.create();
cpuFacet.setModel("Opteron");
+
resourceRegistryContextClient.delete("bad5f350-345c-11e9-9f49-cef9b1608c3f");
cpuFacet.setVendor("AMD");
+
</source>
hostingNode.addFacet(cpuFacet);
+
  
isIdentifiedBy = new IsIdentifiedByImpl<Resource, Facet>(hostingNode, networkingFacet, null);
+
Delete using context instance. This normally used when we already have the context instance.
hostingNode.attachFacet(isIdentifiedBy);
+
  
PropagationConstraint propagationConstraint = new PropagationConstraintImpl();
+
<source lang="java">
propagationConstraint.setRemoveConstraint(RemoveConstraint.cascade);
+
ResourceRegistryContextClient resourceRegistryContextClient = ResourceRegistryContextClientFactory.create();
propagationConstraint.setAddConstraint(AddConstraint.unpropagate);
+
Context nextNextContext = resourceRegistryContextClient.read("bad5f350-345c-11e9-9f49-cef9b1608c3f");
 +
resourceRegistryContextClient.delete(nextNextContext);
 +
</source>
  
Hosts<HostingNode, EService> hosts = new HostsImpl<HostingNode, EService>(hostingNode, eService, propagationConstraint);
+
==== Delete via REST API ====
hostingNode.attachResource(hosts);
+
  
hostingNode = resourceRegistryPublisher.createResource(hostingNode);
+
<pre>DELETE /resource-registry/contexts/{{UUID}}</pre>
</pre>
+
  
 +
{|class="wikitable"
 +
! Code
 +
! Type
 +
! Description
 +
|-
 +
| 204 - No Content
 +
| N/A
 +
| N/A
 +
|}
  
There are also two other equivalent methods with the following signature:
 
 
<pre>
 
public String createResource(String resource) throws ResourceAlreadyPresentException, ResourceRegistryException;
 
 
public String createResource(String resourceType, String resource) throws ResourceAlreadyPresentException, ResourceRegistryException;
 
</pre>
 
 
The first methods get the Resource to be created as JSON string instead of as Java class.
 
The second get also the '''resourceType''' as parameter (which as to be specified as PATH PARAMETER in the request) avoiding to force client to retrieve it from the string.
 
The second method is more efficient but you have to be sure that the '''resourceType''' is the same specified in the header of the serialized resource.
 
 
==== Update Resource Instance ====
 
 
===== REST API =====
 
<pre>
 
POST /resource-registry/er/resource/670eeabf-76c7-493f-a449-4e6e139a2e84
 
</pre>
 
 
'''''Request Body'''''
 
<pre>
 
{
 
"@class":"HostingNode",
 
"header":{"uuid":"670eeabf-76c7-493f-a449-4e6e139a2e84", ...},
 
"consistsOf":[
 
{
 
"@class":"ConsistsOf",
 
"header":{"uuid":"9d0b1b2b-ac4e-40a9-8dea-bec90076e0ca", ...},
 
"target":{
 
"@class":"CPUFacet",
 
"header":{"uuid":"1daef6a8-5ca4-4700-844b-2a2d784e17b0", ...},
 
"model":"Opteron",
 
"vendor":"AMD",
 
"clockSpeed":"1 GHz"
 
}
 
},{
 
"@class":"IsIdentifiedBy",
 
"header":{"uuid":"02a7072c-4f72-4568-945b-9ddccc881e9f", ...},
 
"target":{
 
"@class":"NetworkingFacet",
 
"header":{"uuid":"59617b01-5856-4d8e-b85c-590a42039933", ...},
 
"ipAddress" : "146.48.87.183",
 
"hostName": "pc-frosini.isti.cnr.it",
 
"domainName" : "isti.cnr.it",
 
"mask" : "255.255.248.0",
 
"broadcastAddress":"146.48.87.255",
 
"username":"luca.frosini" /* Added this property */
 
}
 
}
 
]
 
}
 
</pre>
 
 
'''''Response'''''
 
<pre>
 
{
 
"@class":"HostingNode",
 
"header":{"uuid":"670eeabf-76c7-493f-a449-4e6e139a2e84", ...},
 
"consistsOf":[
 
{
 
"@class":"ConsistsOf",
 
"header":{"uuid":"9d0b1b2b-ac4e-40a9-8dea-bec90076e0ca", ...},
 
"target":{
 
"@class":"CPUFacet",
 
"header":{"uuid":"1daef6a8-5ca4-4700-844b-2a2d784e17b0", ...},
 
"model":"Opteron",
 
"vendor":"AMD",
 
"clockSpeed":"1 GHz"
 
}
 
},{
 
"@class":"IsIdentifiedBy",
 
"header":{"uuid":"02a7072c-4f72-4568-945b-9ddccc881e9f", ...},
 
"target":{
 
"@class":"NetworkingFacet",
 
"header":{"uuid":"59617b01-5856-4d8e-b85c-590a42039933", ...},
 
"ipAddress" : "146.48.87.183",
 
"hostName": "pc-frosini.isti.cnr.it",
 
"domainName" : "isti.cnr.it",
 
"mask" : "255.255.248.0",
 
"broadcastAddress":"146.48.87.255",
 
"username":"luca.frosini"
 
}
 
}
 
]
 
}
 
</pre>
 
 
===== Java API =====
 
<pre>
 
public <R extends Resource> R updateResource(R resource) throws ResourceNotFoundException, ResourceRegistryException;
 
</pre>
 
 
====== Example ======
 
 
<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);
 
</pre>
 
 
There are also two other equivalent methods with the following signature:
 
 
<pre>
 
public String updateResource(String resource) throws ResourceNotFoundException, ResourceRegistryException;
 
public String updateResource(UUID uuid, String resource) throws ResourceNotFoundException, ResourceRegistryException;
 
</pre>
 
 
The first methods get the Resource to be created as JSON string instead of as Java class.
 
The second get also the '''uuid''' as parameter (which as to be specified as PATH PARAMETER in the request) avoiding to force client to retrieve it from the string.
 
The second method is more efficient but you have to be sure that the '''uuid''' is the same specified in the header of the serialized resource.
 
 
==== Delete Resource Instance ====
 
 
===== REST API =====
 
<pre>
 
DELETE /resource-registry/er/resource/670eeabf-76c7-493f-a449-4e6e139a2e84
 
</pre>
 
 
===== Java API =====
 
<pre>
 
public <R extends Resource> boolean deleteResource(R resource) throws ResourceNotFoundException, ResourceRegistryException;
 
</pre>
 
 
====== Example ======
 
 
<pre>
 
boolean deleted = resourceRegistryPublisher.deleteResource(hostingNode);
 
</pre>
 
 
There is also another equivalent methods with the following signature:
 
 
<pre>
 
public boolean deleteResource(UUID uuid) throws ResourceNotFoundException, ResourceRegistryException;
 
</pre>
 
 
The method just need the UUID of the Resource to be deleted.
 
 
=== Relation Instances APIs ===
 
==== ConsistsOf ====
 
 
===== Create ConsistsOf Instance =====
 
 
====== REST API ======
 
 
'''Example 1'''
 
<pre>
 
PUT /resource-registry/er/consistsOf/IsIdentifiedBy
 
</pre>
 
 
In this example the target Facet already exists. The Service set automatically
 
the [[Facet_Based_Resource_Model#PropagationConstraint Propagation Constraint]]
 
to default values (i.e. remove=cascadeWhenOrphan, add=propagate)
 
 
'''''Request Body'''''
 
<pre>
 
{
 
"@class":"IsIdentifiedBy",
 
"source" : {
 
"@class":"HostingNode",
 
"header":{"uuid":"670eeabf-76c7-493f-a449-4e6e139a2e84"} // The HostingNode must be already created. The header with UUId is enough.
 
}
 
"target":{
 
"@class":"NetworkingFacet",
 
"header":{"uuid":"59617b01-5856-4d8e-b85c-590a42039933"},
 
/* In this example we suppose that the NetworkingFacet already exists, so the UUID is enought to attach it by using IsIdentifiedBy relation */
 
}
 
}
 
</pre>
 
 
'''''Response'''''
 
<pre>
 
{
 
"@class":"IsIdentifiedBy",
 
"propagationConstraint":{
 
"add":"propagate",
 
"remove": "cascadeWhenOrphan"
 
},
 
"header":{"uuid":"02a7072c-4f72-4568-945b-9ddccc881e9f", ...},
 
"target":{
 
"@class":"NetworkingFacet",
 
"header":{"uuid":"59617b01-5856-4d8e-b85c-590a42039933", ...},
 
"ipAddress" : "146.48.87.183",
 
"hostName": "pc-frosini.isti.cnr.it",
 
"domainName" : "isti.cnr.it",
 
"mask" : "255.255.248.0",
 
"broadcastAddress":"146.48.87.255"
 
}
 
}
 
</pre>
 
 
'''Example 2'''
 
 
<pre>
 
PUT /resource-registry/er/consistsOf/ConsistsOf
 
</pre>
 
 
In this example the target Facet is created contestually with ConsistsOf relation.
 
Moreover the [[Facet_Based_Resource_Model#PropagationConstraint Propagation Constraint]]
 
are explicitly set (i.e. remove=cascade, add=propagate).
 
 
'''''Request Body'''''
 
<pre>
 
{
 
"@class":"ConsistsOf",
 
"propagationConstraint":{
 
"add":"propagate",
 
"remove": "cascade"
 
},
 
"source" : {
 
"@class":"HostingNode",
 
"header":{"uuid":"670eeabf-76c7-493f-a449-4e6e139a2e84"} // The HostingNode must be already created. The header with UUId is enough.
 
}
 
"target":{
 
"@class":"CPUFacet",
 
"model":"Opteron",
 
"vendor":"AMD",
 
"clockSpeed":"3 GHz"
 
}
 
}
 
</pre>
 
 
'''''Response'''''
 
<pre>
 
{
 
"@class":"ConsistsOf",
 
"header":{"uuid":"9bff49c8-c0a7-45de-827c-accb71defbd3", ...},
 
"propagationConstraint":{
 
"add":"propagate",
 
"remove": "cascade"
 
},
 
"target":{
 
"@class":"CPUFacet",
 
"header":{"uuid":"1daef6a8-5ca4-4700-844b-2a2d784e17b0", ...},
 
"model":"Opteron",
 
"vendor":"AMD",
 
"clockSpeed":"1 GHz"
 
}
 
}
 
</pre>
 
 
====== Java API ======
 
 
<pre>
 
public <C extends ConsistsOf<? extends Resource, ? extends Facet>> C createConsistsOf(C consistsOf) throws FacetNotFoundException, ResourceNotFoundException, ResourceRegistryException;
 
</pre>
 
 
'''Example 1'''
 
 
<pre>
 
IsIdentifiedBy isIdentifiedBy = new IsIdentifiedByImpl<Resource, Facet>(hostingNode, networkingFacet, null);
 
resourceRegistryPublisher.createConsistsOf(isIdentifiedBy);
 
</pre>
 
 
'''Example 2'''
 
 
<pre>
 
CPUFacet cpuFacet = new CPUFacetImpl();
 
cpuFacet.setClockSpeed("1 GHz");
 
cpuFacet.setModel("Opteron");
 
cpuFacet.setVendor("AMD");
 
 
PropagationConstraint propagationConstraint = new PropagationConstraintImpl();
 
propagationConstraint.setRemoveConstraint(RemoveConstraint.cascade);
 
propagationConstraint.setAddConstraint(AddConstraint.propagate);
 
 
ConsistsOf consistsOf = new ConsistsOfImpl<Resource, Facet>(hostingNode, cpuFacet, propagationConstraint);
 
consistsOf = resourceRegistryPublisher.createConsistsOf(consistsOf);
 
</pre>
 
 
 
There are also two other equivalent methods with the following signature:
 
 
<pre>
 
public String createConsistsOf(String consistsOfType, String consistsOf) throws FacetNotFoundException, ResourceNotFoundException, ResourceRegistryException;
 
 
public String createConsistsOf(String consistsOf) throws FacetNotFoundException, ResourceNotFoundException, ResourceRegistryException;
 
</pre>
 
 
The first methods get the Resource to be created as JSON string instead of as Java class.
 
The second get also the '''consistsOfType''' as parameter (which as to be specified as PATH PARAMETER in the request) avoiding to force client to retrieve it from the string.
 
The second method is more efficient but you have to be sure that the '''consistsOfType''' is the same specified in the header of the serialized resource.
 
 
===== Delete ConsistsOf Instance =====
 
 
====== REST API ======
 
 
<pre>
 
DELETE /resource-registry/er/consistsOf/02a7072c-4f72-4568-945b-9ddccc881e9f
 
</pre>
 
 
<pre>
 
DELETE /resource-registry/er/consistsOf/9bff49c8-c0a7-45de-827c-accb71defbd3
 
</pre>
 
 
 
====== Java API ======
 
<pre>
 
public <C extends ConsistsOf<? extends Resource, ? extends Facet>> boolean deleteConsistsOf(C consistsOf) throws ResourceRegistryException;
 
</pre>
 
 
<pre>
 
boolean deleted = resourceRegistryPublisher.deleteConsistsOf(isIdentifiedBy);
 
</pre>
 
 
<pre>
 
boolean deleted = resourceRegistryPublisher.deleteConsistsOf(consistsOf);
 
</pre>
 
 
 
There is also another equivalent methods with the following signature:
 
 
<pre>
 
public boolean deleteConsistsOf(UUID uuid) throws ResourceRegistryException;
 
</pre>
 
 
 
<pre>
 
UUID uuid = UUID.fromString("9bff49c8-c0a7-45de-827c-accb71defbd3")
 
boolean deleted = resourceRegistryPublisher.deleteConsistsOf(uuid);
 
</pre>
 
 
The method just need the UUID of the ConsistsOf relation to be deleted.
 
 
== Query & Access ==
 
 
 
=== Exists ===
 
 
<pre>HEAD /resource-registry/access/instance/{ER-Type}/{INSTANCE UUID}</pre>
 
 
Example
 
 
<pre>HEAD /resource-registry/access/instance/ContactFacet/4d28077b-566d-4132-b073-f4edaf61dcb9</pre>
 
 
 
=== Get Instance ===
 
 
<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 09: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