Resource Registry Service - Context Management

From Gcube Wiki
Revision as of 09:38, 9 September 2021 by Luca.frosini (Talk | contribs) (Resource Registry Context Client)

(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search

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