Difference between revisions of "Resource Registry Service - Context Management"
Luca.frosini (Talk | contribs) m (Luca.frosini moved page Interacting with Resource Registry Service - Context and Schema Port Type to Resource Registry Service - Context Management) |
Luca.frosini (Talk | contribs) (→Types Management) |
||
Line 997: | Line 997: | ||
* '''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 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.''' | * '''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.''' | ||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− |
Revision as of 13:40, 1 July 2021
These sections provide information regarding how to interact with Resource Registry Service for Context and Type 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
It is responsible for managing hierarchical Context as defined by the IS Model.
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.
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 exposes the common functionalities of any collection as recommended by ROA such as:
- 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:
- Delete: allows to delete a Context.
The following table shows the exposed HTTP APIs for contexts 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}
|
Java Client
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>
Context Collection
List
List all available contexts.
GET /resource-registry/contexts
We have 5 Contexts organized in the following Context Tree:
- 007f9154-25fa-4f52-9cd4-ec1f8c3c3ba (testROOT) | |---- 30bdb3cc-cf18-4d26-bdb7-0bb8ffb481eb (testVO) | | | |---- 55e3f48e-2aaf-4a2d-89c4-05cb43822c4a (testVRE) | |---- cbe1855b-97c5-495e-a24d-b04428bb4ef6 (anotherVO)
[ { "name": "testRoot", "header": { "@class": "Header", "creator": "luca.frosini", "creationTime": "2020-10-30 17:03:42.339 +0100", "modifiedBy": "luca.frosini", "uuid": "007f9154-25fa-4f52-9cd4-ec1f8c3c3baf", "lastUpdateTime": "2020-10-30 17:03:42.339 +0100" }, "@class": "Context", "@superClasses": [ "EntityElement" ], "children": [ { "header": { "@class": "Header", "creator": "luca.frosini", "creationTime": "2020-10-30 17:03:46.215 +0100", "modifiedBy": "luca.frosini", "uuid": "197d9848-378b-430b-a30d-008d30cbd4b4", "lastUpdateTime": "2020-10-30 17:03:46.215 +0100" }, "@class": "IsParentOf", "@superClasses": [ "RelationElement" ], "target": { "name": "testVO", "header": { "@class": "Header", "creator": "luca.frosini", "creationTime": "2020-10-30 17:03:46.223 +0100", "modifiedBy": "luca.frosini", "uuid": "30bdb3cc-cf18-4d26-bdb7-0bb8ffb481eb", "lastUpdateTime": "2020-10-30 17:03:46.223 +0100" }, "@class": "Context", "@superClasses": [ "EntityElement" ] } }, { "header": { "@class": "Header", "creator": "luca.frosini", "creationTime": "2020-10-30 17:03:49.997 +0100", "modifiedBy": "luca.frosini", "uuid": "cd21b948-4a84-4843-aa5a-3c801a6a87fa", "lastUpdateTime": "2020-10-30 17:03:49.997 +0100" }, "@class": "IsParentOf", "@superClasses": [ "RelationElement" ], "target": { "name": "anotherVO", "header": { "@class": "Header", "creator": "luca.frosini", "creationTime": "2020-10-30 17:03:50.006 +0100", "modifiedBy": "luca.frosini", "uuid": "cbe1855b-97c5-495e-a24d-b04428bb4ef6", "lastUpdateTime": "2020-10-30 17:03:50.006 +0100" }, "@class": "Context", "@superClasses": [ "EntityElement" ] } } ] }, { "name": "testVO", "header": { "@class": "Header", "creator": "luca.frosini", "creationTime": "2020-10-30 17:03:46.223 +0100", "modifiedBy": "luca.frosini", "uuid": "30bdb3cc-cf18-4d26-bdb7-0bb8ffb481eb", "lastUpdateTime": "2020-10-30 17:03:46.223 +0100" }, "@class": "Context", "@superClasses": [ "EntityElement" ], "parent": { "header": { "@class": "Header", "creator": "luca.frosini", "creationTime": "2020-10-30 17:03:46.215 +0100", "modifiedBy": "luca.frosini", "uuid": "197d9848-378b-430b-a30d-008d30cbd4b4", "lastUpdateTime": "2020-10-30 17:03:46.215 +0100" }, "@class": "IsParentOf", "@superClasses": [ "RelationElement" ], "source": { "name": "testRoot", "header": { "@class": "Header", "creator": "luca.frosini", "creationTime": "2020-10-30 17:03:42.339 +0100", "modifiedBy": "luca.frosini", "uuid": "007f9154-25fa-4f52-9cd4-ec1f8c3c3baf", "lastUpdateTime": "2020-10-30 17:03:42.339 +0100" }, "@class": "Context", "@superClasses": [ "EntityElement" ] } }, "children": [ { "header": { "@class": "Header", "creator": "luca.frosini", "creationTime": "2020-10-30 17:03:54.633 +0100", "modifiedBy": "luca.frosini", "uuid": "282064cc-d71a-4ac4-9228-2e459d2880f2", "lastUpdateTime": "2020-10-30 17:03:54.633 +0100" }, "@class": "IsParentOf", "@superClasses": [ "RelationElement" ], "target": { "name": "testVRE", "header": { "@class": "Header", "creator": "luca.frosini", "creationTime": "2020-10-30 17:03:54.643 +0100", "modifiedBy": "luca.frosini", "uuid": "55e3f48e-2aaf-4a2d-89c4-05cb43822c4a", "lastUpdateTime": "2020-10-30 17:03:54.643 +0100" }, "@class": "Context", "@superClasses": [ "EntityElement" ] } } ] }, { "name": "testVRE", "header": { "@class": "Header", "creator": "luca.frosini", "creationTime": "2020-10-30 17:03:54.643 +0100", "modifiedBy": "luca.frosini", "uuid": "55e3f48e-2aaf-4a2d-89c4-05cb43822c4a", "lastUpdateTime": "2020-10-30 17:03:54.643 +0100" }, "@class": "Context", "@superClasses": [ "EntityElement" ], "parent": { "header": { "@class": "Header", "creator": "luca.frosini", "creationTime": "2020-10-30 17:03:54.633 +0100", "modifiedBy": "luca.frosini", "uuid": "282064cc-d71a-4ac4-9228-2e459d2880f2", "lastUpdateTime": "2020-10-30 17:03:54.633 +0100" }, "@class": "IsParentOf", "@superClasses": [ "RelationElement" ], "source": { "name": "testVO", "header": { "@class": "Header", "creator": "luca.frosini", "creationTime": "2020-10-30 17:03:46.223 +0100", "modifiedBy": "luca.frosini", "uuid": "30bdb3cc-cf18-4d26-bdb7-0bb8ffb481eb", "lastUpdateTime": "2020-10-30 17:03:46.223 +0100" }, "@class": "Context", "@superClasses": [ "EntityElement" ] } } }, { "name": "anotherVO", "header": { "@class": "Header", "creator": "luca.frosini", "creationTime": "2020-10-30 17:03:50.006 +0100", "modifiedBy": "luca.frosini", "uuid": "cbe1855b-97c5-495e-a24d-b04428bb4ef6", "lastUpdateTime": "2020-10-30 17:03:50.006 +0100" }, "@class": "Context", "@superClasses": [ "EntityElement" ], "parent": { "header": { "@class": "Header", "creator": "luca.frosini", "creationTime": "2020-10-30 17:03:49.997 +0100", "modifiedBy": "luca.frosini", "uuid": "cd21b948-4a84-4843-aa5a-3c801a6a87fa", "lastUpdateTime": "2020-10-30 17:03:49.997 +0100" }, "@class": "IsParentOf", "@superClasses": [ "RelationElement" ], "source": { "name": "testRoot", "header": { "@class": "Header", "creator": "luca.frosini", "creationTime": "2020-10-30 17:03:42.339 +0100", "modifiedBy": "luca.frosini", "uuid": "007f9154-25fa-4f52-9cd4-ec1f8c3c3baf", "lastUpdateTime": "2020-10-30 17:03:42.339 +0100" }, "@class": "Context", "@superClasses": [ "EntityElement" ] } } } ]
Create
PUT /resource-registry/contexts/{{UUID}}
Description
Create new Context as child of another Context (if any).
Example 1
Create a new Context with name testROOT with no parent. It is a ROOT Context.
Request URL
PUT /resource-registry/context/007f9154-25fa-4f52-9cd4-ec1f8c3c3baf
Body
{ "@class": "Context", "name": "testRoot", "header": { "@class": "Header", "uuid": "007f9154-25fa-4f52-9cd4-ec1f8c3c3baf" } }
Response Body
{ "name": "testRoot", "header": { "@class": "Header", "creator": "luca.frosini", "creationTime": "2020-10-30 17:03:42.339 +0100", "modifiedBy": "luca.frosini", "uuid": "007f9154-25fa-4f52-9cd4-ec1f8c3c3baf", "lastUpdateTime": "2020-10-30 17:03:42.339 +0100" }, "@class": "Context", "@superClasses": [ "EntityElement" ] }
Example 2
Create a new Context with name testVO as child of Context with UUID 007f9154-25fa-4f52-9cd4-ec1f8c3c3baf (testROOT).
Request URL
PUT /resource-registry/contexts/30bdb3cc-cf18-4d26-bdb7-0bb8ffb481eb
Body
{ "@class": "Context", "header": { "@class": "Header", "uuid": "30bdb3cc-cf18-4d26-bdb7-0bb8ffb481eb" }, "name": "testVO", "parent": { "@class": "IsParentOf", "source": { "@class": "Context", "header": { "@class": "Header", "uuid": "007f9154-25fa-4f52-9cd4-ec1f8c3c3baf" } } } }
Response Body
{ "name": "testVO", "header": { "@class": "Header", "creator": "luca.frosini", "creationTime": "2020-10-30 17:03:46.223 +0100", "modifiedBy": "luca.frosini", "uuid": "30bdb3cc-cf18-4d26-bdb7-0bb8ffb481eb", "lastUpdateTime": "2020-10-30 17:03:46.223 +0100" }, "@class": "Context", "@superClasses": [ "EntityElement" ], "parent": { "header": { "@class": "Header", "creator": "luca.frosini", "creationTime": "2020-10-30 17:03:46.215 +0100", "modifiedBy": "luca.frosini", "uuid": "197d9848-378b-430b-a30d-008d30cbd4b4", "lastUpdateTime": "2020-10-30 17:03:46.215 +0100" }, "@class": "IsParentOf", "@superClasses": [ "RelationElement" ], "source": { "name": "testRoot", "header": { "@class": "Header", "creator": "luca.frosini", "creationTime": "2020-10-30 17:03:42.339 +0100", "modifiedBy": "luca.frosini", "uuid": "007f9154-25fa-4f52-9cd4-ec1f8c3c3baf", "lastUpdateTime": "2020-10-30 17:03:42.339 +0100" }, "@class": "Context", "@superClasses": [ "EntityElement" ] } } }
Create With Java Client
This Java code snippet shows how to create contexts used in examples 1 and 2.
ResourceRegistryContextClient resourceRegistryContextClient = ResourceRegistryContextClientFactory.create(); Context testROOTContext = new ContextImpl("testROOT"); // Java class generate a random UUID and use to interact with Resource Regsitry Service // To specify the UUID // UUID testROOTUUID = UUID.fromString("007f9154-25fa-4f52-9cd4-ec1f8c3c3baf"); // Context testROOTContext = new ContextImpl("testROOT", testROOTUUID); testROOTContext = resourceRegistryContextClient.create(testROOTContext); Context testVOContext = new ContextImpl("testVO"); // To specify the UUID // UUID testVOUUID = UUID.fromString("30bdb3cc-cf18-4d26-bdb7-0bb8ffb481eb"); // Context testVOContext = new ContextImpl("testVO", testVOTUUID); testVOContext.setParent(testROOTContext); testVOContext = resourceRegistryContextClient.create(testVOContext);
Read
GET /resource-registry/context/{UUID}
Description
Return the definition of the Context identified by the UUID provided as the path parameter.
Example 1
Read the Context having UUID 007f9154-25fa-4f52-9cd4-ec1f8c3c3baf
Request URL
GET /resource-registry/contexts/007f9154-25fa-4f52-9cd4-ec1f8c3c3baf
Response Body
{ "name": "testRoot", "header": { "@class": "Header", "creator": "luca.frosini", "creationTime": "2020-10-30 17:03:42.339 +0100", "modifiedBy": "luca.frosini", "uuid": "007f9154-25fa-4f52-9cd4-ec1f8c3c3baf", "lastUpdateTime": "2020-10-30 17:03:42.339 +0100" }, "@class": "Context", "@superClasses": [ "EntityElement" ], "children": [ { "header": { "@class": "Header", "creator": "luca.frosini", "creationTime": "2020-10-30 17:03:46.215 +0100", "modifiedBy": "luca.frosini", "uuid": "197d9848-378b-430b-a30d-008d30cbd4b4", "lastUpdateTime": "2020-10-30 17:03:46.215 +0100" }, "@class": "IsParentOf", "@superClasses": [ "RelationElement" ], "target": { "name": "testVO", "header": { "@class": "Header", "creator": "luca.frosini", "creationTime": "2020-10-30 17:03:46.223 +0100", "modifiedBy": "luca.frosini", "uuid": "30bdb3cc-cf18-4d26-bdb7-0bb8ffb481eb", "lastUpdateTime": "2020-10-30 17:03:46.223 +0100" }, "@class": "Context", "@superClasses": [ "EntityElement" ] } }, { "header": { "@class": "Header", "creator": "luca.frosini", "creationTime": "2020-10-30 17:03:49.997 +0100", "modifiedBy": "luca.frosini", "uuid": "cd21b948-4a84-4843-aa5a-3c801a6a87fa", "lastUpdateTime": "2020-10-30 17:03:49.997 +0100" }, "@class": "IsParentOf", "@superClasses": [ "RelationElement" ], "target": { "name": "anotherVO", "header": { "@class": "Header", "creator": "luca.frosini", "creationTime": "2020-10-30 17:03:50.006 +0100", "modifiedBy": "luca.frosini", "uuid": "cbe1855b-97c5-495e-a24d-b04428bb4ef6", "lastUpdateTime": "2020-10-30 17:03:50.006 +0100" }, "@class": "Context", "@superClasses": [ "EntityElement" ] } } ] }
Example 2
Read the Context having UUID 30bdb3cc-cf18-4d26-bdb7-0bb8ffb481eb
Request URL
GET /resource-registry/contexts/30bdb3cc-cf18-4d26-bdb7-0bb8ffb481eb
Response Body
{ "name": "testVO", "header": { "@class": "Header", "creator": "luca.frosini", "creationTime": "2020-10-30 17:03:46.223 +0100", "modifiedBy": "luca.frosini", "uuid": "30bdb3cc-cf18-4d26-bdb7-0bb8ffb481eb", "lastUpdateTime": "2020-10-30 17:03:46.223 +0100" }, "@class": "Context", "@superClasses": [ "EntityElement" ], "parent": { "header": { "@class": "Header", "creator": "luca.frosini", "creationTime": "2020-10-30 17:03:46.215 +0100", "modifiedBy": "luca.frosini", "uuid": "197d9848-378b-430b-a30d-008d30cbd4b4", "lastUpdateTime": "2020-10-30 17:03:46.215 +0100" }, "@class": "IsParentOf", "@superClasses": [ "RelationElement" ], "source": { "name": "testRoot", "header": { "@class": "Header", "creator": "luca.frosini", "creationTime": "2020-10-30 17:03:42.339 +0100", "modifiedBy": "luca.frosini", "uuid": "007f9154-25fa-4f52-9cd4-ec1f8c3c3baf", "lastUpdateTime": "2020-10-30 17:03:42.339 +0100" }, "@class": "Context", "@superClasses": [ "EntityElement" ] } }, "children": [ { "header": { "@class": "Header", "creator": "luca.frosini", "creationTime": "2020-10-30 17:03:54.633 +0100", "modifiedBy": "luca.frosini", "uuid": "282064cc-d71a-4ac4-9228-2e459d2880f2", "lastUpdateTime": "2020-10-30 17:03:54.633 +0100" }, "@class": "IsParentOf", "@superClasses": [ "RelationElement" ], "target": { "name": "testVRE", "header": { "@class": "Header", "creator": "luca.frosini", "creationTime": "2020-10-30 17:03:54.643 +0100", "modifiedBy": "luca.frosini", "uuid": "55e3f48e-2aaf-4a2d-89c4-05cb43822c4a", "lastUpdateTime": "2020-10-30 17:03:54.643 +0100" }, "@class": "Context", "@superClasses": [ "EntityElement" ] } } ] }
Read With Java Client
Read using a string representing the UUID.
ResourceRegistryContextClient resourceRegistryContextClient = ResourceRegistryContextClientFactory.create(); Context testVOContext = resourceRegistryContextClient.read("30bdb3cc-cf18-4d26-bdb7-0bb8ffb481eb");
Read using UUID. This normally used when we already have the UUID instance.
ResourceRegistryContextClient resourceRegistryContextClient = ResourceRegistryContextClientFactory.create(); UUID testVOUUID = UUID.fromString("30bdb3cc-cf18-4d26-bdb7-0bb8ffb481eb"); Context testVOContext = resourceRegistryContextClient.read(testVOUUID);
Read using context instace. This normally used when we already have the context instance.
UUID testVOUUID = UUID.fromString("30bdb3cc-cf18-4d26-bdb7-0bb8ffb481eb"); Context testVOContext = new ContextImpl("testVO", testVOTUUID); ResourceRegistryContextClient resourceRegistryContextClient = ResourceRegistryContextClientFactory.create(); Context testVOContext = resourceRegistryContextClient.read(testVOContext);
Update
PUT /resource-registry/contexts/{UUID}
Description
Update a Context identified by the UUID provided as the path parameter.
The possible updates are on:
- name;
- parent Context.
Rename Context
Rename a Context 007f9154-25fa-4f52-9cd4-ec1f8c3c3baf (was testVO) to the new name devVO.
Request URL
PUT /resource-registry/contexts/007f9154-25fa-4f52-9cd4-ec1f8c3c3baf
Body
{ "@class": "Context", "header": { "@class": "Header", "uuid": "30bdb3cc-cf18-4d26-bdb7-0bb8ffb481eb" }, "name": "devVO", "parent": { "@class": "IsParentOf", "source": { "@class": "Context", "header": { "@class": "Header", "uuid": "007f9154-25fa-4f52-9cd4-ec1f8c3c3baf" }, "name": "test" } } }
Response Body
{ "name": "devVO", "header": { "@class": "Header", "creator": "luca.frosini", "creationTime": "2020-10-30 17:03:46.223 +0100", "modifiedBy": "luca.frosini", "uuid": "30bdb3cc-cf18-4d26-bdb7-0bb8ffb481eb", "lastUpdateTime": "2020-10-30 17:11:03.714 +0100" }, "@class": "Context", "@superClasses": [ "EntityElement" ], "parent": { "header": { "@class": "Header", "creator": "luca.frosini", "creationTime": "2020-10-30 17:03:46.215 +0100", "modifiedBy": "luca.frosini", "uuid": "197d9848-378b-430b-a30d-008d30cbd4b4", "lastUpdateTime": "2020-10-30 17:03:46.215 +0100" }, "@class": "IsParentOf", "@superClasses": [ "RelationElement" ], "source": { "name": "testRoot", "header": { "@class": "Header", "creator": "luca.frosini", "creationTime": "2020-10-30 17:03:42.339 +0100", "modifiedBy": "luca.frosini", "uuid": "007f9154-25fa-4f52-9cd4-ec1f8c3c3baf", "lastUpdateTime": "2020-10-30 17:03:42.339 +0100" }, "@class": "Context", "@superClasses": [ "EntityElement" ] } }, "children": [ { "header": { "@class": "Header", "creator": "luca.frosini", "creationTime": "2020-10-30 17:03:54.633 +0100", "modifiedBy": "luca.frosini", "uuid": "282064cc-d71a-4ac4-9228-2e459d2880f2", "lastUpdateTime": "2020-10-30 17:03:54.633 +0100" }, "@class": "IsParentOf", "@superClasses": [ "RelationElement" ], "target": { "name": "testVRE", "header": { "@class": "Header", "creator": "luca.frosini", "creationTime": "2020-10-30 17:03:54.643 +0100", "modifiedBy": "luca.frosini", "uuid": "55e3f48e-2aaf-4a2d-89c4-05cb43822c4a", "lastUpdateTime": "2020-10-30 17:03:54.643 +0100" }, "@class": "Context", "@superClasses": [ "EntityElement" ] } } ] }
Move Context
We have 5 Contexts organized in the following Context Tree:
- 007f9154-25fa-4f52-9cd4-ec1f8c3c3ba (testROOT) | |---- 30bdb3cc-cf18-4d26-bdb7-0bb8ffb481eb (testVO) | | | |---- 55e3f48e-2aaf-4a2d-89c4-05cb43822c4a (testVRE) | |---- cbe1855b-97c5-495e-a24d-b04428bb4ef6 (anotherVO)
We want to move Context 55e3f48e-2aaf-4a2d-89c4-05cb43822c4a (testVRE) as child of the Context cbe1855b-97c5-495e-a24d-b04428bb4ef6 (anotherVO) in palce of 30bdb3cc-cf18-4d26-bdb7-0bb8ffb481eb (testVO)
We will obtain the following Context tree
- 007f9154-25fa-4f52-9cd4-ec1f8c3c3ba (testROOT) | |---- 30bdb3cc-cf18-4d26-bdb7-0bb8ffb481eb (testVO) | |---- cbe1855b-97c5-495e-a24d-b04428bb4ef6 (anotherVO) | | | |---- 55e3f48e-2aaf-4a2d-89c4-05cb43822c4a (testVRE)
If we read the Context 55e3f48e-2aaf-4a2d-89c4-05cb43822c4a' (testVRE) before moving it we have:
{ "name": "testVRE", "header": { "@class": "Header", "creator": "luca.frosini", "creationTime": "2020-10-30 17:03:54.643 +0100", "modifiedBy": "luca.frosini", "uuid": "55e3f48e-2aaf-4a2d-89c4-05cb43822c4a", "lastUpdateTime": "2020-10-30 17:16:00.768 +0100" }, "@class": "Context", "@superClasses": [ "EntityElement" ], "parent": { "header": { "@class": "Header", "creator": "luca.frosini", "creationTime": "2020-10-30 17:16:00.755 +0100", "modifiedBy": "luca.frosini", "uuid": "a6ab3939-6f6b-4d2d-9ef1-497a8330ea5e", "lastUpdateTime": "2020-10-30 17:16:00.755 +0100" }, "@class": "IsParentOf", "@superClasses": [ "RelationElement" ], "source": { "name": "testVO", "header": { "@class": "Header", "creator": "luca.frosini", "creationTime": "2020-10-30 17:03:46.223 +0100", "modifiedBy": "luca.frosini", "uuid": "30bdb3cc-cf18-4d26-bdb7-0bb8ffb481eb", "lastUpdateTime": "2020-10-30 17:13:02.481 +0100" }, "@class": "Context", "@superClasses": [ "EntityElement" ] } } }
Request URL
PUT /resource-registry/contexts/55e3f48e-2aaf-4a2d-89c4-05cb43822c4a
Body
{ "@class": "Context", "header": { "@class": "Header", "uuid": "55e3f48e-2aaf-4a2d-89c4-05cb43822c4a" }, "name": "testVRE", "parent": { "@class": "IsParentOf", "source": { "@class": "Context", "header": { "@class": "Header", "uuid": "cbe1855b-97c5-495e-a24d-b04428bb4ef6" } } } }
Response Body
{ "name": "testVRE", "header": { "@class": "Header", "creator": "luca.frosini", "creationTime": "2020-10-30 17:03:54.643 +0100", "modifiedBy": "luca.frosini", "uuid": "55e3f48e-2aaf-4a2d-89c4-05cb43822c4a", "lastUpdateTime": "2020-10-30 17:16:38.592 +0100" }, "@class": "Context", "@superClasses": [ "EntityElement" ], "parent": { "header": { "@class": "Header", "creator": "luca.frosini", "creationTime": "2020-10-30 17:16:38.580 +0100", "modifiedBy": "luca.frosini", "uuid": "170cc2b2-e772-4e07-a0a2-6f9f36ac6b12", "lastUpdateTime": "2020-10-30 17:16:38.580 +0100" }, "@class": "IsParentOf", "@superClasses": [ "RelationElement" ], "source": { "name": "anotherVO", "header": { "@class": "Header", "creator": "luca.frosini", "creationTime": "2020-10-30 17:03:50.006 +0100", "modifiedBy": "luca.frosini", "uuid": "cbe1855b-97c5-495e-a24d-b04428bb4ef6", "lastUpdateTime": "2020-10-30 17:03:50.006 +0100" }, "@class": "Context", "@superClasses": [ "EntityElement" ] } } }
Delete
DELETE /resource-registry/contexts/{{UUID}}
Delete the Context identified by the UUID provided as the path parameter.
For example to delete the Context having UUID 55e3f48e-2aaf-4a2d-89c4-05cb43822c4a we just need to perform the following HTTP request
DELETE /resource-registry/contexts/55e3f48e-2aaf-4a2d-89c4-05cb43822c4a
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.