Difference between revisions of "Resource Registry Service - Instances Sharing Management"

From Gcube Wiki
Jump to: navigation, search
(APIs)
(Instances Sharing Management)
 
(11 intermediate revisions by the same user not shown)
Line 13: Line 13:
  
 
Instances Sharing Management is responsible for sharing between Contexts. It offers the following APIs:
 
Instances Sharing Management is responsible for sharing between Contexts. It offers the following APIs:
* Add To Context: it allows add an instance to a context;
+
* '''Add To Context''': it allows add an instance to a context;
* Remove From Context: it allows to remove an instance from a context (the Resource Registry deletes the instance when it is available only in the removing context).
+
* '''Remove From Context''': it allows to remove an instance from a context (the Resource Registry deletes the instance when it is available only in the removing context).
 
+
  
 
The Instances Sharing Management implements the following policies:
 
The Instances Sharing Management implements the following policies:
Line 23: Line 22:
 
* it guarantees propagation constraints.
 
* it guarantees propagation constraints.
  
When the resource registry receives a request to add a resource instance to a context (or remove from a context), it applies the propagation constraints defined in the outcoming relations.
+
When the resource registry receives a request to add a resource instance to a context (or remove it from a context), it applies the propagation constraints defined in the outcoming relations.
 
This behaviour can have a "cascade impact" because also the target resource will be added (removed) and so forth.
 
This behaviour can have a "cascade impact" because also the target resource will be added (removed) and so forth.
  
Any request to add an instance to context has a source context which means that the resource registry analysed only the propagation constraint of the relations belonging to the source contexts.
+
Any request to add an instance to context has a source context, meaning that the resource registry analysed only the propagation constraint of the relations belonging to the source contexts.
 
Hence, sharing an instance from context C1 to context C3 can have a different result than sharing the same instance from the context C2 to the context C3.
 
Hence, sharing an instance from context C1 to context C3 can have a different result than sharing the same instance from the context C2 to the context C3.
  
Line 75: Line 74:
 
ResourceRegistryPublisher resourceRegistryPublisher = ResourceRegistryPublisherFactory.create();
 
ResourceRegistryPublisher resourceRegistryPublisher = ResourceRegistryPublisherFactory.create();
 
</source>
 
</source>
 
  
 
== APIs ==
 
== APIs ==
Line 84: Line 82:
  
 
<source lang="java">
 
<source lang="java">
 +
public List<ERElement> addToContext(String type, UUID instanceUUID, UUID contextUUID) throws SchemaViolationException, NotFoundException, ResourceRegistryException;
 +
 +
public List<ERElement> addToContext(ERElement er, UUID contextUUID) throws SchemaViolationException, NotFoundException, ResourceRegistryException;
 +
 +
public List<ERElement> addToCurrentContext(String type, UUID instanceUUID) throws SchemaViolationException, NotFoundException, ResourceRegistryException;
 +
 +
public List<ERElement> addToCurrentContext(ERElement er) throws SchemaViolationException, NotFoundException, ResourceRegistryException;
 
</source>
 
</source>
 +
 +
''ERElement'' is the base class of ''Entity'' (base class of ''Resource'' and ''Facet'') and ''Relation'' (base class of ''IsRelatedTo'' and ''ConsistsOf'') classes.
  
 
===== Add To Context via Java Client Example =====
 
===== Add To Context via Java Client Example =====
  
 
<source lang="java">
 
<source lang="java">
 +
ResourceRegistryPublisher resourceRegistryPublisher = ResourceRegistryPublisherFactory.create();
 +
resourceRegistryPublisher.addToContext("EService", "7f37a79d-0c00-4166-8a68-165de0a438bf", "aa860961-6eb0-4c1c-89fb-c406fe2a2771");
 
</source>
 
</source>
  
Line 690: Line 699:
  
 
<source lang="java">
 
<source lang="java">
 +
public List<ERElement> removeFromContext(String type, UUID instanceUUID, UUID contextUUID) throws SchemaViolationException, NotFoundException, ResourceRegistryException;
 +
 +
public List<ERElement> removeFromContext(ERElement er, UUID contextUUID)throws SchemaViolationException, ResourceNotFoundException, ContextNotFoundException, ResourceRegistryException;
 +
 +
public List<ERElement> removeFromCurrentContext(String type, UUID instanceUUID) throws SchemaViolationException, ResourceNotFoundException, ContextNotFoundException, ResourceRegistryException;
 +
 +
public List<ERElement> removeFromCurrentContext(ERElement er) throws SchemaViolationException, ResourceNotFoundException, ContextNotFoundException, ResourceRegistryException;
 
</source>
 
</source>
  
Line 695: Line 711:
  
 
<source lang="java">
 
<source lang="java">
 +
ResourceRegistryPublisher resourceRegistryPublisher = ResourceRegistryPublisherFactory.create();
 +
resourceRegistryPublisher.removeFromContext("EService", "7f37a79d-0c00-4166-8a68-165de0a438bf", "aa860961-6eb0-4c1c-89fb-c406fe2a2771");
 
</source>
 
</source>
  

Latest revision as of 14:45, 6 July 2021

These sections provide information regarding how to interact with Resource Registry Service for Entities and Relations instances sharing between Contexts. REST and JAVA API are presented for each functionality.

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

Instances Sharing Management

Instances Sharing Management is responsible for sharing between Contexts. It offers the following APIs:

  • Add To Context: it allows add an instance to a context;
  • Remove From Context: it allows to remove an instance from a context (the Resource Registry deletes the instance when it is available only in the removing context).

The Instances Sharing Management implements the following policies:

  • it manages the Header automatically;
  • it validates the instance against the schema of the defined type;
  • it guarantees propagation constraints.

When the resource registry receives a request to add a resource instance to a context (or remove it from a context), it applies the propagation constraints defined in the outcoming relations. This behaviour can have a "cascade impact" because also the target resource will be added (removed) and so forth.

Any request to add an instance to context has a source context, meaning that the resource registry analysed only the propagation constraint of the relations belonging to the source contexts. Hence, sharing an instance from context C1 to context C3 can have a different result than sharing the same instance from the context C2 to the context C3.

Instances Sharing Collection

The following table shows the exposed APIs as REST Collection

Operation HTTP Method URL
Add Instance To Context POST /sharing/contexts/{CONTEXT_UUID}/{TYPE_NAME}/{INSTANCE_UUID}?operation=ADD[&dryRun=false]
Remove Instance From Context POST /sharing/contexts/{CONTEXT_UUID}/{TYPE_NAME}/{INSTANCE_UUID}?operation=REMOVE[&dryRun=false]

Each operation returns the list of affected instances (both entities and relations)

The service offers the capability of simulating the operation specifying true to dryRun query parameter. This is possible thanks to the returned list of affected instances even in dryRun mode.

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 types rather than Resource Manager.

Resource Registry Publisher

Resource Registry Publisher is a java library providing RPC facilities to interact with Instances Management and Instances Sharing Management. 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 Instances Collection declare the following dependency in your pom.xml file.

<dependency>
	<groupId>org.gcube.information-system</groupId>
	<artifactId>resource-registry-publisher</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.publisher.ResourceRegistryPublisher;
import org.gcube.informationsystem.resourceregistry.publisher.ResourceRegistryPublisherFactory;
 
...
 
ResourceRegistryPublisher resourceRegistryPublisher = ResourceRegistryPublisherFactory.create();

APIs

Add To Context

Add To Context via Java Client

public List<ERElement> addToContext(String type, UUID instanceUUID, UUID contextUUID) throws SchemaViolationException, NotFoundException, ResourceRegistryException;
 
public List<ERElement> addToContext(ERElement er, UUID contextUUID) throws SchemaViolationException, NotFoundException, ResourceRegistryException;
 
public List<ERElement> addToCurrentContext(String type, UUID instanceUUID) throws SchemaViolationException, NotFoundException, ResourceRegistryException;
 
public List<ERElement> addToCurrentContext(ERElement er) throws SchemaViolationException, NotFoundException, ResourceRegistryException;

ERElement is the base class of Entity (base class of Resource and Facet) and Relation (base class of IsRelatedTo and ConsistsOf) classes.

Add To Context via Java Client Example
ResourceRegistryPublisher resourceRegistryPublisher = ResourceRegistryPublisherFactory.create();
resourceRegistryPublisher.addToContext("EService", "7f37a79d-0c00-4166-8a68-165de0a438bf", "aa860961-6eb0-4c1c-89fb-c406fe2a2771");

Add To Context via REST API

POST  /sharing/contexts/{CONTEXT_UUID}/{TYPE_NAME}/{INSTANCE_UUID}?operation=ADD
Code Type Description
200 String A JSON Array containing the list of instances added to the context
Add To Context via REST API Example

To add to the context devNext (UUID=aa860961-6eb0-4c1c-89fb-c406fe2a2771) the EService with UUID 7f37a79d-0c00-4166-8a68-165de0a438bf we need to invoke the following APIs

Request URL

POST /sharing/contexts/aa860961-6eb0-4c1c-89fb-c406fe2a2771/EService/7f37a79d-0c00-4166-8a68-165de0a438bf?operation=ADD

Response Body

[
    {
        "date": "2021-06-30 16:38:26.464 +0200",
        "header": {
            "@class": "Header",
            "creationTime": "2021-07-01 08:51:02.346 +0200",
            "createdBy": "luca.frosini",
            "uuid": "6142d408-f43c-4db7-851f-1dfeb4d98b99",
            "lastUpdateBy": "luca.frosini",
            "lastUpdateTime": "2021-07-01 12:15:57.585 +0200"
        },
        "event": {
            "@class": "ValueSchema",
            "schema": "String",
            "value": "started"
        },
        "@class": "EventFacet",
        "@superClasses": [
            "Facet"
        ]
    },
    {
        "header": {
            "@class": "Header",
            "creationTime": "2021-07-01 08:51:02.341 +0200",
            "createdBy": "luca.frosini",
            "uuid": "d5e73a7f-d85b-437b-ab2e-64c94061c5ff",
            "lastUpdateBy": "luca.frosini",
            "lastUpdateTime": "2021-07-01 12:15:57.572 +0200"
        },
        "propagationConstraint": {
            "@class": "PropagationConstraint",
            "add": "propagate",
            "remove": "cascade"
        },
        "@class": "ConsistsOf",
        "@superClasses": []
    },
    {
        "header": {
            "@class": "Header",
            "creationTime": "2021-07-01 08:51:02.350 +0200",
            "createdBy": "luca.frosini",
            "uuid": "f1a41f5c-42a3-47ec-b289-6811e62a1c94",
            "lastUpdateBy": "luca.frosini",
            "lastUpdateTime": "2021-07-01 12:15:57.602 +0200"
        },
        "propagationConstraint": {
            "@class": "PropagationConstraint",
            "add": "propagate",
            "remove": "cascade"
        },
        "@class": "ConsistsOf",
        "@superClasses": []
    },
    {
        "name": "WhnManager",
        "description": "Web Hosting Node Service",
        "header": {
            "@class": "Header",
            "creationTime": "2021-07-01 08:51:02.298 +0200",
            "createdBy": "luca.frosini",
            "uuid": "97984812-90e6-4eb7-b804-50a9ad3fe4fb",
            "lastUpdateBy": "luca.frosini",
            "lastUpdateTime": "2021-07-01 12:15:57.296 +0200"
        },
        "optional": "false",
        "version": "2.0.0-4.15.0-132431",
        "group": "VREManagement",
        "@class": "SoftwareFacet",
        "@superClasses": [
            "Facet"
        ]
    },
    {
        "header": {
            "@class": "Header",
            "creationTime": "2021-07-01 08:51:02.312 +0200",
            "createdBy": "luca.frosini",
            "uuid": "3b653a72-b182-41d6-bcc5-97e0141f0ceb",
            "lastUpdateBy": "luca.frosini",
            "lastUpdateTime": "2021-07-01 12:15:57.442 +0200"
        },
        "propagationConstraint": {
            "@class": "PropagationConstraint",
            "add": "propagate",
            "remove": "cascade"
        },
        "@class": "IsIdentifiedBy",
        "@superClasses": [
            "ConsistsOf"
        ]
    },
    {
        "header": {
            "@class": "Header",
            "creationTime": "2021-07-01 08:51:02.353 +0200",
            "createdBy": "luca.frosini",
            "uuid": "7f37a79d-0c00-4166-8a68-165de0a438bf",
            "lastUpdateBy": "luca.frosini",
            "lastUpdateTime": "2021-07-01 12:15:57.605 +0200"
        },
        "@class": "EService",
        "@superClasses": [
            "Service",
            "GCubeResource",
            "Resource"
        ]
    },
    {
        "header": {
            "@class": "Header",
            "creationTime": "2021-07-01 08:51:02.332 +0200",
            "createdBy": "luca.frosini",
            "uuid": "d4aec29c-3f18-4464-94ae-5fb77306eb82",
            "lastUpdateBy": "luca.frosini",
            "lastUpdateTime": "2021-07-01 12:15:57.542 +0200"
        },
        "propagationConstraint": {
            "@class": "PropagationConstraint",
            "add": "propagate",
            "remove": "cascade"
        },
        "@class": "ConsistsOf",
        "@superClasses": []
    },
    {
        "header": {
            "@class": "Header",
            "creationTime": "2021-07-01 08:51:02.336 +0200",
            "createdBy": "luca.frosini",
            "uuid": "44abfa06-a78b-4e5a-a0c5-aa8fe7bcbcf9",
            "lastUpdateBy": "luca.frosini",
            "lastUpdateTime": "2021-07-01 12:15:57.555 +0200"
        },
        "value": "started",
        "@class": "StateFacet",try (dryRun) 
        "@superClasses": [
            "Facet"
        ]
    },
    {
        "authorization": {
            "@class": "ValueSchema",
            "type": null,
            "value": "gcube-token"
        },
        "endpoint": "http://pc-frosini.isti.cnr.it:8080/whn-manager/gcube/vremanagement/ws/whnmanager",
        "entryName": "whnmanager",
        "header": {
            "@class": "Header",
            "creationTime": "2021-07-01 08:51:02.318 +0200",
            "createdBy": "luca.frosini",
            "uuid": "f66a9fdf-3d5c-45fd-8437-6fecec463c4c",
            "lastUpdateBy": "luca.frosini",
            "lastUpdateTime": "2021-07-01 12:15:57.502 +0200"
        },
        "@class": "AccessPointFacet",
        "@superClasses": [
            "Facet"
        ]
    },
    {
        "authorization": {
            "@class": "ValueSchema",
            "type": null,
            "value": "gcube-token"
        },
        "endpoint": "http://pc-frosini.isti.cnr.it:8080/whn-manager/gcube/resource",
        "entryName": "WhnManager-remote-management",
        "header": {
            "@class": "Header",
            "creationTime": "2021-07-01 08:51:02.327 +0200",
            "createdBy": "luca.frosini",
            "uuid": "a18eb180-398e-4302-942e-c3d7e55ad4try (dryRun) 96",
            "lastUpdateBy": "luca.frosini",
            "lastUpdateTime": "2021-07-01 12:15:57.534 +0200"
        },
        "@class": "AccessPointFacet",
        "@superClasses": [
            "Facet"
        ]
    },
    {
        "header": {
            "@class": "Header",
            "creationTime": "2021-07-01 08:51:02.322 +0200",
            "createdBy": "luca.frosini",
            "uuid": "5c78bec3-2fa6-46b3-892d-d41bed93e136",
            "lastUpdateBy": "luca.frosini",
            "lastUpdateTime": "2021-07-01 12:15:57.520 +0200"
        },
        "propagationConstraint": {
            "@class": "PropagationConstraint",
            "add": "propagate",
            "remove": "cascade"
        },
        "@class": "ConsistsOf",
        "@superClasses": []
    }
]

As we can notice every instance (entities an relations) has been enumerated individually.

Add To Context Proof

If we read now the EService instance requesting to include the contexts in the header we will have also the added context:

Request URL

GET /instances/EService/7f37a79d-0c00-4166-8a68-165de0a438bf?includeContextsInHeader=true

Response Body

{
    "header": {
        "@class": "Header",
        "creationTime": "2021-07-01 08:51:02.353 +0200",
        "createdBy": "luca.frosini",
        "uuid": "7f37a79d-0c00-4166-8a68-165de0a438bf",
        "lastUpdateBy": "luca.frosini",
        "lastUpdateTime": "2021-07-01 12:35:26.334 +0200",
        "contexts": [
            "ca50eb95-b76c-44fd-9182-229d39c3c9e2",
            "aa860961-6eb0-4c1c-89fb-c406fe2a2771"
        ]
    },
    "@class": "EService",
    "@superClasses": [
        "Service",
        "GCubeResource",
        "Resource"
    ],
    "consistsOf": [
        {
            "header": {
                "@class": "Header",
                "creationTime": "2021-07-01 08:51:02.312 +0200",
                "createdBy": "luca.frosini",
                "uuid": "3b653a72-b182-41d6-bcc5-97e0141f0ceb",
                "lastUpdateBy": "luca.frosini",
                "lastUpdateTime": "2021-07-01 12:35:26.281 +0200",
                "contexts": [
                    "ca50eb95-b76c-44fd-9182-229d39c3c9e2",
                    "aa860961-6eb0-4c1c-89fb-c406fe2a2771"
                ]
            },
            "propagationConstraint": {
                "@class": "PropagationConstraint",
                "add": "propagate",
                "remove": "cascade"
            },
            "@class": "IsIdentifiedBy",
            "@superClasses": [
                "ConsistsOf"
            ],
            "source": {
                "header": {
                    "@class": "Header",
                    "creationTime": "2021-07-01 08:51:02.353 +0200",
                    "createdBy": "luca.frosini",
                    "uuid": "7f37a79d-0c00-4166-8a68-165de0a438bf",
                    "lastUpdateBy": "luca.frosini",
                    "lastUpdateTime": "2021-07-01 12:35:26.334 +0200",
                    "contexts": [
                        "ca50eb95-b76c-44fd-9182-229d39c3c9e2",
                        "aa860961-6eb0-4c1c-89fb-c406fe2a2771"
                    ]
                },
                "@class": "EService",
                "@superClasses": [
                    "Service",
                    "GCubeResource",
                    "Resource"
                ]
            },
            "target": {
                "name": "WhnManager",
                "description": "Web Hosting Node Service",
                "header": {
                    "@class": "Header",
                    "creationTime": "2021-07-01 08:51:02.298 +0200",
                    "createdBy": "luca.frosini",
                    "uuid": "97984812-90e6-4eb7-b804-50a9ad3fe4fb",
                    "lastUpdateBy": "luca.frosini",
                    "lastUpdateTime": "2021-07-01 12:35:26.274 +0200",
                    "contexts": [
                        "ca50eb95-b76c-44fd-9182-229d39c3c9e2",
                        "aa860961-6eb0-4c1c-89fb-c406fe2a2771"
                    ]
                },
                "optional": "false",
                "version": "2.0.0-4.15.0-132431",
                "group": "VREManagement",
                "@class": "SoftwareFacet",
                "@superClasses": [
                    "Facet"
                ]
            }
        },
        {
            "header": {
                "@class": "Header",
                "creationTime": "2021-07-01 08:51:02.322 +0200",
                "createdBy": "luca.frosini",
                "uuid": "5c78bec3-2fa6-46b3-892d-d41bed93e136",
                "lastUpdateBy": "luca.frosini",
                "lastUpdateTime": "2021-07-01 12:35:26.298 +0200",
                "contexts": [
                    "ca50eb95-b76c-44fd-9182-229d39c3c9e2",
                    "aa860961-6eb0-4c1c-89fb-c406fe2a2771"
                ]
            },
            "propagationConstraint": {
                "@class": "PropagationConstraint",
                "add": "propagate",
                "remove": "cascade"
            },
            "@class": "ConsistsOf",
            "@superClasses": [],
            "source": {
                "header": {
                    "@class": "Header",
                    "creationTime": "2021-07-01 08:51:02.353 +0200",
                    "createdBy": "luca.frosini",
                    "uuid": "7f37a79d-0c00-4166-8a68-165de0a438bf",
                    "lastUpdateBy": "luca.frosini",
                    "lastUpdateTime": "2021-07-01 12:35:26.334 +0200",
                    "contexts": [
                        "ca50eb95-b76c-44fd-9182-229d39c3c9e2",
                        "aa860961-6eb0-4c1c-89fb-c406fe2a2771"
                    ]
                },
                "@class": "EService",
                "@superClasses": [
                    "Service",
                    "GCubeResource",
                    "Resource"
                ]
            },
            "target": {
                "authorization": {
                    "@class": "ValueSchema",
                    "type": null,
                    "value": "gcube-token"
                },
                "endpoint": "http://pc-frosini.isti.cnr.it:8080/whn-manager/gcube/vremanagement/ws/whnmanager",
                "entryName": "whnmanager",
                "header": {
                    "@class": "Header",
                    "creationTime": "2021-07-01 08:51:02.318 +0200",
                    "createdBy": "luca.frosini",
                    "uuid": "f66a9fdf-3d5c-45fd-8437-6fecec463c4c",
                    "lastUpdateBy": "luca.frosini",
                    "lastUpdateTime": "2021-07-01 12:35:26.290 +0200",
                    "contexts": [
                        "ca50eb95-b76c-44fd-9182-229d39c3c9e2",
                        "aa860961-6eb0-4c1c-89fb-c406fe2a2771"
                    ]
                },
                "@class": "AccessPointFacet",
                "@superClasses": [
                    "Facet"
                ]
            }
        },
        {
            "header": {
                "@class": "Header",
                "creationTime": "2021-07-01 08:51:02.332 +0200",
                "createdBy": "luca.frosini",
                "uuid": "d4aec29c-3f18-4464-94ae-5fb77306eb82",
                "lastUpdateBy": "luca.frosini",
                "lastUpdateTime": "2021-07-01 12:35:26.311 +0200",
                "contexts": [
                    "ca50eb95-b76c-44fd-9182-229d39c3c9e2",
                    "aa860961-6eb0-4c1c-89fb-c406fe2a2771"
                ]
            },
            "propagationConstraint": {
                "@class": "PropagationConstraint",
                "add": "propagate",
                "remove": "cascade"
            },
            "@class": "ConsistsOf",
            "@superClasses": [],
            "source": {
                "header": {
                    "@class": "Header",
                    "creationTime": "2021-07-01 08:51:02.353 +0200",
                    "createdBy": "luca.frosini",
                    "uuid": "7f37a79d-0c00-4166-8a68-165de0a438bf",
                    "lastUpdateBy": "luca.frosini",
                    "lastUpdateTime": "2021-07-01 12:35:26.334 +0200",
                    "contexts": [
                        "ca50eb95-b76c-44fd-9182-229d39c3c9e2",
                        "aa860961-6eb0-4c1c-89fb-c406fe2a2771"
                    ]
                },
                "@class": "EService",
                "@superClasses": [
                    "Service",
                    "GCubeResource",
                    "Resource"
                ]
            },
            "target": {
                "authorization": {
                    "@class": "ValueSchema",
                    "type": null,
                    "value": "gcube-token"
                },
                "endpoint": "http://pc-frosini.isti.cnr.it:8080/whn-manager/gcube/resource",
                "entryName": "WhnManager-remote-management",
                "header": {
                    "@class": "Header",
                    "creationTime": "2021-07-01 08:51:02.327 +0200",
                    "createdBy": "luca.frosini",
                    "uuid": "a18eb180-398e-4302-942e-c3d7e55ad496",
                    "lastUpdateBy": "luca.frosini",
                    "lastUpdateTime": "2021-07-01 12:35:26.306 +0200",
                    "contexts": [
                        "ca50eb95-b76c-44fd-9182-229d39c3c9e2",
                        "aa860961-6eb0-4c1c-89fb-c406fe2a2771"
                    ]
                },
                "@class": "AccessPointFacet",
                "@superClasses": [
                    "Facet"
                ]
            }
        },
        {
            "header": {
                "@class": "Header",
                "creationTime": "2021-07-01 08:51:02.341 +0200",
                "createdBy": "luca.frosini",
                "uuid": "d5e73a7f-d85b-437b-ab2e-64c94061c5ff",
                "lastUpdateBy": "luca.frosini",
                "lastUpdateTime": "2021-07-01 12:35:26.322 +0200",
                "contexts": [
                    "ca50eb95-b76c-44fd-9182-229d39c3c9e2",
                    "aa860961-6eb0-4c1c-89fb-c406fe2a2771"
                ]
            },
            "propagationConstraint": {
                "@class": "PropagationConstraint",
                "add": "propagate",
                "remove": "cascade"
            },
            "@class": "ConsistsOf",
            "@superClasses": [],
            "source": {
                "header": {
                    "@class": "Header",
                    "creationTime": "2021-07-01 08:51:02.353 +0200",
                    "createdBy": "luca.frosini",
                    "uuid": "7f37a79d-0c00-4166-8a68-165de0a438bf",
                    "lastUpdateBy": "luca.frosini",
                    "lastUpdateTime": "2021-07-01 12:35:26.334 +0200",
                    "contexts": [
                        "ca50eb95-b76c-44fd-9182-229d39c3c9e2",
                        "aa860961-6eb0-4c1c-89fb-c406fe2a2771"
                    ]
                },
                "@class": "EService",
                "@superClasses": [
                    "Service",
                    "GCubeResource",
                    "Resource"
                ]
            },
            "target": {
                "header": {
                    "@class": "Header",
                    "creationTime": "2021-07-01 08:51:02.336 +0200",
                    "createdBy": "luca.frosini",
                    "uuid": "44abfa06-a78b-4e5a-a0c5-aa8fe7bcbcf9",
                    "lastUpdateBy": "luca.frosini",
                    "lastUpdateTime": "2021-07-01 12:35:26.318 +0200",
                    "contexts": [
                        "ca50eb95-b76c-44fd-9182-229d39c3c9e2",
                        "aa860961-6eb0-4c1c-89fb-c406fe2a2771"
                    ]
                },
                "value": "started",
                "@class": "StateFacet",
                "@superClasses": [
                    "Facet"
                ]
            }
        },
        {
            "header": {
                "@class": "Header",
                "creationTime": "2021-07-01 08:51:02.350 +0200",
                "createdBy": "luca.frosini",
                "uuid": "f1a41f5c-42a3-47ec-b289-6811e62a1c94",
                "lastUpdateBy": "luca.frosini",
                "lastUpdateTime": "2021-07-01 12:35:26.332 +0200",
                "contexts": [
                    "ca50eb95-b76c-44fd-9182-229d39c3c9e2",
                    "aa860961-6eb0-4c1c-89fb-c406fe2a2771"
                ]
            },
            "propagationConstraint": {
                "@class": "PropagationConstraint",
                "add": "propagate",
                "remove": "cascade"
            },
            "@class": "ConsistsOf",
            "@superClasses": [],
            "source": {
                "header": {
                    "@class": "Header",
                    "creationTime": "2021-07-01 08:51:02.353 +0200",
                    "createdBy": "luca.frosini",
                    "uuid": "7f37a79d-0c00-4166-8a68-165de0a438bf",
                    "lastUpdateBy": "luca.frosini",
                    "lastUpdateTime": "2021-07-01 12:35:26.334 +0200",
                    "contexts": [
                        "ca50eb95-b76c-44fd-9182-229d39c3c9e2",
                        "aa860961-6eb0-4c1c-89fb-c406fe2a2771"
                    ]
                },
                "@class": "EService",
                "@superClasses": [
                    "Service",
                    "GCubeResource",
                    "Resource"
                ]
            },
            "target": {
                "date": "2021-06-30 16:38:26.464 +0200",
                "header": {
                    "@class": "Header",
                    "creationTime": "2021-07-01 08:51:02.346 +0200",
                    "createdBy": "luca.frosini",
                    "uuid": "6142d408-f43c-4db7-851f-1dfeb4d98b99",
                    "lastUpdateBy": "luca.frosini",
                    "lastUpdateTime": "2021-07-01 12:35:26.328 +0200",
                    "contexts": [
                        "ca50eb95-b76c-44fd-9182-229d39c3c9e2",
                        "aa860961-6eb0-4c1c-89fb-c406fe2a2771"
                    ]
                },
                "event": {
                    "@class": "ValueSchema",
                    "schema": "String",
                    "value": "started"
                },
                "@class": "EventFacet",
                "@superClasses": [
                    "Facet"
                ]
            }
        }
    ]
}

If you try to remove from context the EventFacet you will obtain a Schema Violation Exception because an EService must have one EventFacet. This must be true in every context.

Remove From Context

Remove From Context via Java Client

public List<ERElement> removeFromContext(String type, UUID instanceUUID, UUID contextUUID) throws SchemaViolationException, NotFoundException, ResourceRegistryException;
 
public List<ERElement> removeFromContext(ERElement er, UUID contextUUID)throws SchemaViolationException, ResourceNotFoundException, ContextNotFoundException, ResourceRegistryException;
 
public List<ERElement> removeFromCurrentContext(String type, UUID instanceUUID) throws SchemaViolationException, ResourceNotFoundException, ContextNotFoundException, ResourceRegistryException;
 
public List<ERElement> removeFromCurrentContext(ERElement er) throws SchemaViolationException, ResourceNotFoundException, ContextNotFoundException, ResourceRegistryException;
Remove From Context via Java Client Example
ResourceRegistryPublisher resourceRegistryPublisher = ResourceRegistryPublisherFactory.create();
resourceRegistryPublisher.removeFromContext("EService", "7f37a79d-0c00-4166-8a68-165de0a438bf", "aa860961-6eb0-4c1c-89fb-c406fe2a2771");

Remove From Context via REST API

POST  /sharing/contexts/{CONTEXT_UUID}/{TYPE_NAME}/{INSTANCE_UUID}?operation=REMOVE
Code Type Description
200 String A JSON Array containing the list of instances added to the context
Remove From Context via REST API Example

To remove from the context devNext (UUID=aa860961-6eb0-4c1c-89fb-c406fe2a2771) the EService with UUID 7f37a79d-0c00-4166-8a68-165de0a438bf we need to invoke the following APIs

Request URL

POST /sharing/contexts/aa860961-6eb0-4c1c-89fb-c406fe2a2771/EService/7f37a79d-0c00-4166-8a68-165de0a438bf?operation=REMOVE

The response is similar to the response obtained to the Add to Context operation.