Interface ResourceRegistryContextClient
- All Superinterfaces:
org.gcube.informationsystem.resourceregistry.api.request.RequestInfo
- All Known Implementing Classes:
ResourceRegistryContextClientImpl
public interface ResourceRegistryContextClient
extends org.gcube.informationsystem.resourceregistry.api.request.RequestInfo
Client interface for managing contexts in the Resource Registry system.
Purpose:
This interface provides methods for creating, reading, updating, deleting, and managing the state of contexts
within the Resource Registry. Contexts represent organizational units that contain and organize Information
System resources, facets, and relations.
Instantiation:
Clients should be created using the factory pattern for proper configuration:
// Recommended way to create a client ResourceRegistryContextClient client = ResourceRegistryContextClientFactory.create();Supported Operations:
- CRUD Operations: Create, Read, Update, Delete contexts with full lifecycle management
- State Management: Change context states (ACTIVE, READY, DOWN) with proper validation
- Query Operations: List all contexts with filtering and pagination support
- Current Context: Access the context associated with the current authorization token
- includeMeta: Include metadata in responses (role-based filtering applied)
- limit: Maximum number of results per request
- offset: Number of results to skip for pagination
- IS-Manager: Full access to all contexts and operations
- Infrastructure-Manager: Full access to all contexts and operations
- Context-Manager: Full access only within their managed contexts
- Other Users: Limited read access based on context membership
- ACTIVE: Context is fully operational and accessible
- READY: Context is prepared but not yet active
- DOWN: Context is temporarily unavailable
- Author:
- Luca Frosini (ISTI - CNR)
-
Field Summary
Fields inherited from interface org.gcube.informationsystem.resourceregistry.api.request.RequestInfo
DEFAULT_LIMIT, DEFAULT_OFFSET, UNBOUNDED_LIMIT -
Method Summary
Modifier and TypeMethodDescriptionvoidAdds a custom HTTP header to be included in requests.voidAdds a custom HTTP header to be included in requests.List<org.gcube.informationsystem.contexts.reference.entities.Context>all()Retrieves the list of all contexts in the system.changeState(String context) Changes the state of an existing context from its JSON representation.changeState(String uuid, String state) Changes the state of an existing context using its UUID (as string) and the desired state (as string).org.gcube.informationsystem.contexts.reference.entities.ContextchangeState(UUID uuid, org.gcube.informationsystem.contexts.reference.ContextState state) Changes the state of an existing context using its UUID and the desired state.org.gcube.informationsystem.contexts.reference.entities.ContextchangeState(org.gcube.informationsystem.contexts.reference.entities.Context context) Changes the state of an existing context by extracting its UUID from the provided context object.Creates a new context in the system from its JSON representation.org.gcube.informationsystem.contexts.reference.entities.Contextcreate(org.gcube.informationsystem.contexts.reference.entities.Context context) Creates a new context in the system.booleanDeletes an existing context permanently from the system using its UUID (as string).booleanDeletes an existing context permanently from the system using its UUID.booleandelete(org.gcube.informationsystem.contexts.reference.entities.Context context) Deletes an existing context permanently from the system by extracting its UUID.booleanChecks if a context with the specified UUID (as string) exists in the system.booleanChecks if a context with the specified UUID exists in the system.org.gcube.informationsystem.resourceregistry.api.contexts.ContextCacheGets the context cache used for context-related operations.Retrieves a specific context by its UUID (as string) and returns it as JSON.org.gcube.informationsystem.contexts.reference.entities.ContextRetrieves a specific context by its UUID.org.gcube.informationsystem.contexts.reference.entities.Contextread(org.gcube.informationsystem.contexts.reference.entities.Context context) Retrieves a context by extracting its UUID from the provided context object.org.gcube.informationsystem.contexts.reference.entities.ContextRetrieves the current context associated with the client's authorization token.Updates an existing context in the system from its JSON representation.org.gcube.informationsystem.contexts.reference.entities.Contextupdate(org.gcube.informationsystem.contexts.reference.entities.Context context) Updates an existing context in the system.Methods inherited from interface org.gcube.informationsystem.resourceregistry.api.request.RequestInfo
allMeta, getLimit, getOffset, includeContexts, includeMeta, isHierarchicalMode, setAllMeta, setHierarchicalMode, setIncludeContexts, setIncludeMeta, setLimit, setOffset
-
Method Details
-
addHeader
Adds a custom HTTP header to be included in requests.- Parameters:
name- Header namevalue- Header value
-
addHeader
Adds a custom HTTP header to be included in requests.- Parameters:
name- Header namevalue- boolean value
-
getContextCache
org.gcube.informationsystem.resourceregistry.api.contexts.ContextCache getContextCache()Gets the context cache used for context-related operations.- Returns:
- The context cache instance
-
all
List<org.gcube.informationsystem.contexts.reference.entities.Context> all() throws org.gcube.informationsystem.resourceregistry.api.exceptions.ResourceRegistryExceptionRetrieves the list of all contexts in the system. Corresponding REST API:GET /contexts[?limit={limit}&offset={offset}&includeMeta={true|false}]Operation Behavior:- Returns all contexts that are accessible to the current user
- Results are filtered based on user authorization and context access permissions
- Supports pagination and metadata inclusion based on client configuration
- Returns strongly-typed Context objects with role-appropriate detail level.
- 200 OK: Contexts successfully retrieved
- 403 Forbidden: User lacks authorization to access context information
- 401 Unauthorized: Invalid or missing authentication credentials.
- Whether to include metadata in the response context
- Default value: false (basic context information only)
- Usage:
client.setIncludeMeta(true) - Values: true (includes metadata with role-based filtering) | false (basic information only)
- Query parameter:
ContextPath.INCLUDE_META_QUERY_PARAMETER - Restriction: IS-Manager and Infrastructure-Manager see complete metadata including sensitive information (createdBy, lastUpdatedBy); other users see filtered metadata with sensitive fields obfuscated.
- Maximum number of contexts to return in a single response
- Default value: server configuration dependent
- Usage:
client.setLimit(50) - Example: Set to 50 to get at most 50 contexts per request
- Unlimited results: Set to
RequestInfo.UNBOUNDED_LIMIT(-1) for unlimited results (may cause timeout if results are too many) - Query parameter:
ContextPath.LIMIT_QUERY_PARAMETER.
- Number of contexts to skip from the beginning of the result set
- Default value: 0 (starts from the first context)
- Usage:
client.setOffset(10) - Example: Set to 10 to skip the first 10 contexts (useful for pagination)
- Query parameter:
ContextPath.OFFSET_QUERY_PARAMETER.
- No input parameters required for this method
- All contexts accessible to the current user are returned based on authorization level
- Context filtering is automatically applied based on user permissions.
- IS-Manager: Can retrieve all contexts in the system with complete metadata
- Infrastructure-Manager: Can retrieve all contexts in the system with complete metadata
- Context-Manager: Can retrieve contexts within their management scope
- Other Users: Can retrieve contexts they have explicit access to with filtered metadata.
ResourceRegistryContextClient client = ResourceRegistryContextClientFactory.create(); // Basic usage - get all contexts with default settings List<Context> contexts = client.all(); // With metadata for non-admin users client.setIncludeMeta(true); List<Context> contextsWithMeta = client.all(); // With pagination client.setLimit(50); client.setOffset(10); List<Context> paginatedContexts = client.all();
- Returns:
- list of Context objects with role-appropriate detail level accessible to the current user
- Throws:
org.gcube.informationsystem.resourceregistry.api.exceptions.ResourceRegistryException- if an error occurs during context retrieval or if there are authorization issues
-
create
org.gcube.informationsystem.contexts.reference.entities.Context create(org.gcube.informationsystem.contexts.reference.entities.Context context) throws org.gcube.informationsystem.resourceregistry.api.exceptions.contexts.ContextAlreadyPresentException, org.gcube.informationsystem.resourceregistry.api.exceptions.ResourceRegistryException Creates a new context in the system. This method invokes the REST API endpointPUT /contexts/{context-uuid}from the Resource Registry service. If the context object does not have a UUID, one will be automatically generated. Corresponding REST API:PUT /contexts/{context-uuid}Operation Behavior:- If the context UUID is null, a new UUID will be automatically generated
- The operation will create a new context or update an existing one with the same UUID
- All context properties and relationships are established based on the provided context object
- Returns the created context object with complete information and assigned UUID.
- 201 Created: Context successfully created
- 200 OK: Context successfully updated (if UUID already existed)
- 400 Bad Request: Invalid context data or validation failure
- 409 Conflict: Context with the same name already exists in the parent context
- 403 Forbidden: User lacks authorization to create contexts in the specified location
- 401 Unauthorized: Invalid or missing authentication credentials.
- Whether to include metadata in the response
- Default value: false (basic context information only)
- Usage:
client.setIncludeMeta(true) - Values: true (includes metadata with role-based filtering) | false (basic information only)
- Query parameter:
ContextPath.INCLUDE_META_QUERY_PARAMETER - Restriction: IS-Manager and Infrastructure-Manager see complete metadata including sensitive information (createdBy, lastUpdatedBy); other users see filtered metadata with sensitive fields obfuscated.
- Context object is validated against system constraints
- All context properties and relationships are processed
- UUID assignment is handled automatically if not provided.
- IS-Manager: Can create any context without restrictions and automatically receive full context information including complete metadata
- Infrastructure-Manager: Can create any context without restrictions and automatically receive full context information including complete metadata
- Context-Manager: Can create contexts only if they are Context-Manager of the parent context (the parent context must be the current context retrieved from client's authorization token)
- Other Users: Cannot create contexts and will receive authorization errors if attempting this operation.
- If the context UUID is null, a new UUID will be automatically generated
- The operation will create a new context or update an existing one with the same UUID
- All context properties and relationships are established based on the provided context object
ResourceRegistryContextClient client = ResourceRegistryContextClientFactory.create(); // Create a new context object Context newContext = new ContextImpl(); newContext.setName("MyNewContext"); newContext.setParent(parentContext); // Basic usage - create context Context createdContext = client.create(newContext); // With metadata inclusion for non-admin users client.setIncludeMeta(true); Context contextWithMeta = client.create(newContext);- Parameters:
context- the Context object to create- Returns:
- the created Context object with complete information and assigned UUID
- Throws:
org.gcube.informationsystem.resourceregistry.api.exceptions.contexts.ContextAlreadyPresentException- if a context with the same UUID already exists and creation fails (HTTP 409)org.gcube.informationsystem.resourceregistry.api.exceptions.ResourceRegistryException- if the context cannot be created due to authorization issues or other errors- See Also:
-
create
String create(String context) throws org.gcube.informationsystem.resourceregistry.api.exceptions.contexts.ContextAlreadyPresentException, org.gcube.informationsystem.resourceregistry.api.exceptions.ResourceRegistryException Creates a new context in the system from its JSON representation. This method invokes the REST API endpointPUT /contexts/{context-uuid}from the Resource Registry service. If the context JSON does not contain a UUID, one will be automatically generated. Corresponding REST API:PUT /contexts/{context-uuid}Operation Behavior:- The JSON is parsed to extract context information including UUID, name, parent, and other properties
- If the context UUID is null or missing, a new UUID will be automatically generated
- The operation will create a new context or update an existing one with the same UUID
- All context properties and relationships are established based on the provided JSON
- Returns the created context as JSON string with complete information and assigned UUID.
- 201 Created: Context successfully created
- 200 OK: Context successfully updated (if UUID already existed)
- 400 Bad Request: Invalid context data, JSON format, or validation failure
- 409 Conflict: Context with the same name already exists in the parent context
- 403 Forbidden: User lacks authorization to create contexts in the specified location
- 401 Unauthorized: Invalid or missing authentication credentials.
- Whether to include metadata in the response
- Default value: false (basic context information only)
- Usage:
client.setIncludeMeta(true) - Values: true (includes metadata with role-based filtering) | false (basic information only)
- Query parameter:
ContextPath.INCLUDE_META_QUERY_PARAMETER - Restriction: IS-Manager and Infrastructure-Manager see complete metadata including sensitive information (createdBy, lastUpdatedBy); other users see filtered metadata with sensitive fields obfuscated.
- JSON must be a valid Context representation
- JSON is parsed to extract context information including UUID, name, parent, and other properties
- All context properties are validated against system constraints.
- IS-Manager: Can create any context without restrictions and automatically receive full context information including complete metadata
- Infrastructure-Manager: Can create any context without restrictions and automatically receive full context information including complete metadata
- Context-Manager: Can create contexts only if they are Context-Manager of the parent context (the parent context must be the current context retrieved from client's authorization token)
- Other Users: Cannot create contexts and will receive authorization errors if attempting this operation.
ResourceRegistryContextClient client = ResourceRegistryContextClientFactory.create(); // Create context from JSON string String contextJson = "{\"@class\":\"Context\",\"name\":\"MyNewContext\",\"parent\":{\"id\":\"parent-uuid\"}}"; // Basic usage - create context from JSON String createdContextJson = client.create(contextJson); // With metadata inclusion for non-admin users client.setIncludeMeta(true); String contextWithMeta = client.create(contextJson);- Parameters:
context- the JSON string representation of the context to create- Returns:
- the created context as JSON string with complete information and assigned UUID
- Throws:
org.gcube.informationsystem.resourceregistry.api.exceptions.contexts.ContextAlreadyPresentException- if a context with the same UUID already exists and creation failsorg.gcube.informationsystem.resourceregistry.api.exceptions.ResourceRegistryException- if the context cannot be created due to authorization issues, invalid JSON, or other errors- See Also:
-
exist
boolean exist(UUID uuid) throws org.gcube.informationsystem.resourceregistry.api.exceptions.ResourceRegistryException Checks if a context with the specified UUID exists in the system. Corresponding REST API: Internally usesGET /contexts/{context-uuid}Operation Behavior:- Verifies if a context with the given UUID exists in the system
- Returns
trueif the context exists and is accessible to the current user - Returns
falseif the context does not exist or is not accessible - Does not return the context data, only confirms existence.
- 200 OK: Context exists and is accessible
- 404 Not Found: Context does not exist or is not accessible
- 403 Forbidden: User lacks authorization to access context information
- 401 Unauthorized: Invalid or missing authentication credentials.
- UUID must be a valid UUID format
- Context accessibility is verified based on user authorization level
- Contexts that exist but are not accessible to the user will return
false.
- IS-Manager: Can check existence of any context
- Infrastructure-Manager: Can check existence of any context
- Context-Manager: Can check contexts within their management scope
- Other Users: Can only check contexts they have access to read.
ResourceRegistryContextClient client = ResourceRegistryContextClientFactory.create(); UUID contextUuid = UUID.fromString("c0f314e7-2807-4241-a792-2a6c79ed4fd0"); // Check if context exists if (client.exist(contextUuid)) { System.out.println("Context exists and is accessible"); Context context = client.read(contextUuid); // Process context... } else { System.out.println("Context does not exist or is not accessible"); }- Parameters:
uuid- the UUID of the context to check for existence- Returns:
trueif the context exists and is accessible to the current user,falseotherwise- Throws:
org.gcube.informationsystem.resourceregistry.api.exceptions.ResourceRegistryException- if there are communication errors with the Resource Registry service
-
exist
boolean exist(String uuid) throws org.gcube.informationsystem.resourceregistry.api.exceptions.ResourceRegistryException Checks if a context with the specified UUID (as string) exists in the system. Corresponding REST API: Internally usesGET /contexts/{context-uuid}Operation Behavior:- Converts the string UUID to a UUID object and delegates to
exist(UUID) - Returns
trueif the context exists and is accessible to the current user - Returns
falseif the context does not exist or is not accessible - Does not return the context data, only confirms existence.
- 200 OK: Context exists and is accessible
- 404 Not Found: Context does not exist or is not accessible
- 403 Forbidden: User lacks authorization to access context information
- 401 Unauthorized: Invalid or missing authentication credentials.
- String must be a valid UUID format
- Context accessibility is verified based on user authorization level
- Contexts that exist but are not accessible to the user will return
false.
- IS-Manager: Can check existence of any context
- Infrastructure-Manager: Can check existence of any context
- Context-Manager: Can check contexts within their management scope
- Other Users: Can only check contexts they have access to read.
ResourceRegistryContextClient client = ResourceRegistryContextClientFactory.create(); String contextUuidString = "c0f314e7-2807-4241-a792-2a6c79ed4fd0"; // Check if context exists if (client.exist(contextUuidString)) { System.out.println("Context exists and is accessible"); Context context = client.read(contextUuidString); // Process context... } else { System.out.println("Context does not exist or is not accessible"); } // Alternative: UUID validation try { boolean exists = client.exist(contextUuidString); // Process result... } catch (IllegalArgumentException e) { System.err.println("Invalid UUID format: " + contextUuidString); }- Parameters:
uuid- the UUID of the context (as string) to check for existence- Returns:
trueif the context exists and is accessible to the current user,falseotherwise- Throws:
org.gcube.informationsystem.resourceregistry.api.exceptions.ResourceRegistryException- if there are communication errors with the Resource Registry serviceIllegalArgumentException- if the provided string is not a valid UUID format
- Converts the string UUID to a UUID object and delegates to
-
read
org.gcube.informationsystem.contexts.reference.entities.Context read(org.gcube.informationsystem.contexts.reference.entities.Context context) throws org.gcube.informationsystem.resourceregistry.api.exceptions.contexts.ContextNotFoundException, org.gcube.informationsystem.resourceregistry.api.exceptions.ResourceRegistryException Retrieves a context by extracting its UUID from the provided context object. This is a convenience method that delegates toread(UUID)using the context's ID. Corresponding REST API:GET /contexts/{context-uuid}[?includeMeta={true|false}]Operation Behavior:- Extracts the UUID from the provided context object
- Delegates to
read(UUID)for the actual retrieval operation - Returns the full context object with all accessible properties
- Response detail level varies based on user authorization.
- 200 OK: Context successfully retrieved
- 404 Not Found: Context with the specified UUID is not found
- 403 Forbidden: User lacks authorization to access context information
- 401 Unauthorized: Invalid or missing authentication credentials.
- Whether to include metadata in the response (for non-admin users)
- Default value: false (basic context information only)
- Usage:
client.setIncludeMeta(true) - Values: true (includes metadata with role-based filtering) | false (basic information only)
- Query parameter:
ContextPath.INCLUDE_META_QUERY_PARAMETER - Restriction: IS-Manager and Infrastructure-Manager see complete metadata including sensitive information (createdBy, lastUpdatedBy); other users see filtered metadata with sensitive fields obfuscated.
- Context object must contain a valid UUID
- Only the UUID is used from the provided context object, all other properties are ignored.
- IS-Manager: Can retrieve any context with complete metadata
- Infrastructure-Manager: Can retrieve any context with complete metadata
- Context-Manager: Can retrieve contexts within their management scope
- Other Users: Can retrieve contexts they have access to with filtered metadata.
ResourceRegistryContextClient client = ResourceRegistryContextClientFactory.create(); Context contextStub = new ContextImpl(); contextStub.setID(UUID.fromString("c0f314e7-2807-4241-a792-2a6c79ed4fd0")); // Read the full context using the stub Context fullContext = client.read(contextStub);- Parameters:
context- the context object containing the UUID to retrieve- Returns:
- the complete Context object with role-appropriate detail level
- Throws:
org.gcube.informationsystem.resourceregistry.api.exceptions.contexts.ContextNotFoundException- if the context with the specified UUID is not foundorg.gcube.informationsystem.resourceregistry.api.exceptions.ResourceRegistryException- if there are communication errors or authorization issues
-
read
org.gcube.informationsystem.contexts.reference.entities.Context read(UUID uuid) throws org.gcube.informationsystem.resourceregistry.api.exceptions.contexts.ContextNotFoundException, org.gcube.informationsystem.resourceregistry.api.exceptions.ResourceRegistryException Retrieves a specific context by its UUID. Corresponding REST API:GET /contexts/{context-uuid}[?includeMeta={true|false}]Operation Behavior:- Retrieves the context with the specified UUID from the system
- Returns the complete context object with all accessible properties
- Response detail level varies based on user authorization
- Metadata inclusion is controlled by client configuration and user authorization.
- 200 OK: Context successfully retrieved
- 404 Not Found: Context with the specified UUID is not found
- 403 Forbidden: User lacks authorization to access context information
- 401 Unauthorized: Invalid or missing authentication credentials.
- Whether to include metadata in the response (for non-admin users)
- Default value: false (basic context information only)
- Usage:
client.setIncludeMeta(true) - Values: true (includes metadata with role-based filtering) | false (basic information only)
- Query parameter:
ContextPath.INCLUDE_META_QUERY_PARAMETER - Restriction: IS-Manager and Infrastructure-Manager see complete metadata including sensitive information (createdBy, lastUpdatedBy); other users see filtered metadata with sensitive fields obfuscated.
- UUID must be a valid UUID format
- Context accessibility is verified based on user authorization level.
- IS-Manager: Can retrieve any context with complete metadata
- Infrastructure-Manager: Can retrieve any context with complete metadata
- Context-Manager: Can retrieve contexts within their management scope with full information when operating in their own context
- Other Users: Can retrieve contexts they have access to with filtered metadata.
ResourceRegistryContextClient client = ResourceRegistryContextClientFactory.create(); UUID contextUuid = UUID.fromString("c0f314e7-2807-4241-a792-2a6c79ed4fd0"); // Basic usage - read context Context context = client.read(contextUuid); System.out.println("Context name: " + context.getName()); // With metadata for non-admin users client.setIncludeMeta(true); Context contextWithMeta = client.read(contextUuid);- Parameters:
uuid- the UUID of the context to retrieve- Returns:
- the Context object with role-appropriate detail level
- Throws:
org.gcube.informationsystem.resourceregistry.api.exceptions.contexts.ContextNotFoundException- if the context with the specified UUID is not foundorg.gcube.informationsystem.resourceregistry.api.exceptions.ResourceRegistryException- if there are communication errors or authorization issues
-
read
String read(String uuid) throws org.gcube.informationsystem.resourceregistry.api.exceptions.contexts.ContextNotFoundException, org.gcube.informationsystem.resourceregistry.api.exceptions.ResourceRegistryException Retrieves a specific context by its UUID (as string) and returns it as JSON. This method delegates toread(UUID)and marshals the result to JSON format. Corresponding REST API:GET /contexts/{context-uuid}[?includeMeta={true|false}]Operation Behavior:- Converts the string UUID to a UUID object
- Delegates to
read(UUID)for the actual retrieval operation - Marshals the resulting Context object to JSON format
- Returns the complete context as JSON string with all accessible properties.
- 200 OK: Context successfully retrieved
- 404 Not Found: Context with the specified UUID is not found
- 403 Forbidden: User lacks authorization to access context information
- 401 Unauthorized: Invalid or missing authentication credentials.
- Whether to include metadata in the response (for non-admin users)
- Default value: false (basic context information only)
- Usage:
client.setIncludeMeta(true) - Values: true (includes metadata with role-based filtering) | false (basic information only)
- Query parameter:
ContextPath.INCLUDE_META_QUERY_PARAMETER - Restriction: IS-Manager and Infrastructure-Manager see complete metadata including sensitive information (createdBy, lastUpdatedBy); other users see filtered metadata with sensitive fields obfuscated.
- String must be a valid UUID format
- Context accessibility is verified based on user authorization level.
- IS-Manager: Can retrieve any context with complete metadata
- Infrastructure-Manager: Can retrieve any context with complete metadata
- Context-Manager: Can retrieve contexts within their management scope
- Other Users: Can retrieve contexts they have access to with filtered metadata.
ResourceRegistryContextClient client = ResourceRegistryContextClientFactory.create(); String contextUuidString = "c0f314e7-2807-4241-a792-2a6c79ed4fd0"; // Basic usage - read context as JSON String contextJson = client.read(contextUuidString); System.out.println("Context JSON: " + contextJson); // With metadata for non-admin users client.setIncludeMeta(true); String contextWithMetaJson = client.read(contextUuidString); // Error handling for invalid UUID try { String result = client.read("invalid-uuid-format"); } catch (IllegalArgumentException e) { System.err.println("Invalid UUID format"); }- Parameters:
uuid- the UUID of the context (as string) to retrieve- Returns:
- the Context as JSON string with role-appropriate detail level
- Throws:
org.gcube.informationsystem.resourceregistry.api.exceptions.contexts.ContextNotFoundException- if the context with the specified UUID is not foundorg.gcube.informationsystem.resourceregistry.api.exceptions.ResourceRegistryException- if there are communication errors or authorization issuesIllegalArgumentException- if the provided string is not a valid UUID format
-
readCurrentContext
org.gcube.informationsystem.contexts.reference.entities.Context readCurrentContext() throws org.gcube.informationsystem.resourceregistry.api.exceptions.contexts.ContextNotFoundException, org.gcube.informationsystem.resourceregistry.api.exceptions.ResourceRegistryExceptionRetrieves the current context associated with the client's authorization token. This method extracts the context information from the security context and retrieves the full context object. Corresponding REST API: Equivalent toGET /contexts/CURRENT_CONTEXTbut implemented client-side Operation Behavior:- Extracts the context full name from the current authorization token via
SecretManagerProvider - Resolves the context full name to its UUID
- Delegates to
read(UUID)for the actual context retrieval - Returns the complete context object associated with the current authorization token.
- 200 OK: Current context successfully retrieved
- 404 Not Found: Current context cannot be found or resolved
- 403 Forbidden: User lacks authorization to access their current context
- 401 Unauthorized: Invalid or missing authentication credentials.
- Whether to include metadata in the response (for non-admin users)
- Default value: false (basic context information only)
- Usage:
client.setIncludeMeta(true) - Values: true (includes metadata with role-based filtering) | false (basic information only)
- Query parameter:
ContextPath.INCLUDE_META_QUERY_PARAMETER - Restriction: IS-Manager and Infrastructure-Manager see complete metadata including sensitive information (createdBy, lastUpdatedBy); other users see filtered metadata with sensitive fields obfuscated.
- Context information is automatically extracted from the JWT token
- No explicit input parameters required.
- IS-Manager: Can retrieve current context with complete metadata
- Infrastructure-Manager: Can retrieve current context with complete metadata
- Context-Manager: Can retrieve their current context with full information
- Other Users: Can retrieve their current context (this is typically always granted).
ResourceRegistryContextClient client = ResourceRegistryContextClientFactory.create(); // Get current context Context currentContext = client.readCurrentContext(); System.out.println("Current context: " + currentContext.getName()); System.out.println("Current context UUID: " + currentContext.getID()); // With metadata client.setIncludeMeta(true); Context currentContextWithMeta = client.readCurrentContext(); // Use current context for relative operations if (currentContext.getParent() != null) { Context parentContext = client.read(currentContext.getParent().getID()); System.out.println("Parent context: " + parentContext.getName()); }- Returns:
- the Context object associated with the current authorization token
- Throws:
org.gcube.informationsystem.resourceregistry.api.exceptions.contexts.ContextNotFoundException- if the current context cannot be found or resolvedorg.gcube.informationsystem.resourceregistry.api.exceptions.ResourceRegistryException- if there are communication errors or authorization issues
- Extracts the context full name from the current authorization token via
-
update
org.gcube.informationsystem.contexts.reference.entities.Context update(org.gcube.informationsystem.contexts.reference.entities.Context context) throws org.gcube.informationsystem.resourceregistry.api.exceptions.contexts.ContextNotFoundException, org.gcube.informationsystem.resourceregistry.api.exceptions.ResourceRegistryException Updates an existing context in the system. Corresponding REST API:PUT /contexts/{context-uuid}Operation Behavior:- Updates the context with the specified UUID using the provided context object
- Name Change: Updates the context name while preserving all other properties
- Parent Change (Move Operation): Moves the context to a different parent in the context hierarchy
- Combined Changes: Both name and parent can be changed in the same update request
- Context UUIDs remain stable regardless of name or parent changes.
- 200 OK: Context successfully updated
- 404 Not Found: Context with the specified UUID is not found
- 400 Bad Request: Invalid context data or validation failure
- 403 Forbidden: User lacks authorization to update the context
- 401 Unauthorized: Invalid or missing authentication credentials.
- Whether to include metadata in the response
- Default value: false (basic context information only)
- Usage:
client.setIncludeMeta(true) - Values: true (includes metadata with role-based filtering) | false (basic information only)
- Query parameter:
ContextPath.INCLUDE_META_QUERY_PARAMETER - Restriction: IS-Manager and Infrastructure-Manager see complete metadata including sensitive information (createdBy, lastUpdatedBy); other users see filtered metadata with sensitive fields obfuscated.
- Context object must contain a valid UUID
- All context properties are validated against system constraints
- Name and parent changes are validated for conflicts and authorization.
- IS-Manager: Can update any context without restrictions
- Infrastructure-Manager: Can update any context without restrictions
- Context-Manager: Can update contexts only if they are Context-Manager of the parent context
- Other Users: Cannot update contexts (will receive authorization errors).
ResourceRegistryContextClient client = ResourceRegistryContextClientFactory.create(); // Get context to update Context context = client.read(contextUuid); // Update context name context.setName("NewContextName"); Context updatedContext = client.update(context); // Update with metadata for non-admin users client.setIncludeMeta(true); Context contextWithMeta = client.update(context);- Parameters:
context- the Context object with updated properties- Returns:
- the updated Context object with complete information
- Throws:
org.gcube.informationsystem.resourceregistry.api.exceptions.contexts.ContextNotFoundException- if the context with the specified UUID is not foundorg.gcube.informationsystem.resourceregistry.api.exceptions.ResourceRegistryException- if the context cannot be updated due to authorization issues or other errors
-
update
String update(String context) throws org.gcube.informationsystem.resourceregistry.api.exceptions.contexts.ContextNotFoundException, org.gcube.informationsystem.resourceregistry.api.exceptions.ResourceRegistryException Updates an existing context in the system from its JSON representation. Corresponding REST API:PUT /contexts/{context-uuid}Operation Behavior:- Updates the context using the provided JSON representation
- Name Change: Updates the context name while preserving all other properties
- Parent Change (Move Operation): Moves the context to a different parent in the context hierarchy
- Combined Changes: Both name and parent can be changed in the same update request
- Returns the updated context as JSON string with complete information.
- 200 OK: Context successfully updated
- 404 Not Found: Context with the specified UUID is not found
- 400 Bad Request: Invalid context data, JSON format, or validation failure
- 403 Forbidden: User lacks authorization to update the context
- 401 Unauthorized: Invalid or missing authentication credentials.
- Whether to include metadata in the response
- Default value: false (basic context information only)
- Usage:
client.setIncludeMeta(true) - Values: true (includes metadata with role-based filtering) | false (basic information only)
- Query parameter:
ContextPath.INCLUDE_META_QUERY_PARAMETER - Restriction: IS-Manager and Infrastructure-Manager see complete metadata including sensitive information (createdBy, lastUpdatedBy); other users see filtered metadata with sensitive fields obfuscated.
- JSON must be a valid Context representation
- JSON must contain a valid UUID field to identify the target context
- All context properties are validated against system constraints
- Name and parent changes are validated for conflicts and authorization.
- IS-Manager: Can update any context without restrictions
- Infrastructure-Manager: Can update any context without restrictions
- Context-Manager: Can update contexts only if they are Context-Manager of the parent context
- Other Users: Cannot update contexts (will receive authorization errors).
ResourceRegistryContextClient client = ResourceRegistryContextClientFactory.create(); // Update context from JSON string String contextJson = "{\"@class\":\"Context\",\"id\":\"uuid\",\"name\":\"UpdatedName\"}"; // Basic usage - update context from JSON String updatedContextJson = client.update(contextJson); // With metadata inclusion for non-admin users client.setIncludeMeta(true); String contextWithMeta = client.update(contextJson);- Parameters:
context- the JSON string representation of the context with updated properties- Returns:
- the updated context as JSON string with complete information
- Throws:
org.gcube.informationsystem.resourceregistry.api.exceptions.contexts.ContextNotFoundException- if the context with the specified UUID is not foundorg.gcube.informationsystem.resourceregistry.api.exceptions.ResourceRegistryException- if the context cannot be updated due to authorization issues, invalid JSON, or other errors
-
delete
boolean delete(org.gcube.informationsystem.contexts.reference.entities.Context context) throws org.gcube.informationsystem.resourceregistry.api.exceptions.contexts.ContextNotFoundException, org.gcube.informationsystem.resourceregistry.api.exceptions.ResourceRegistryException Deletes an existing context permanently from the system by extracting its UUID. This is a convenience method that delegates todelete(UUID)using the context's ID. Corresponding REST API:DELETE /contexts/{context-uuid}Operation Behavior:- Extracts the UUID from the provided context object
- Delegates to
delete(UUID)for the actual deletion operation - Context is permanently deleted from the system and moved to a "cemetery" for audit trails and historical tracking
- The UUID becomes permanently unavailable for reuse
- Once deleted, the context cannot be restored through normal operations.
- 200 OK: Context successfully deleted
- 404 Not Found: Context with the specified UUID is not found
- 409 Conflict: Context has child contexts or other dependencies preventing deletion
- 403 Forbidden: User lacks authorization to delete the context
- 401 Unauthorized: Invalid or missing authentication credentials.
- Context object must contain a valid UUID
- Only the UUID is used from the provided context object, all other properties are ignored
- Child Contexts: Cannot delete a context that has child contexts (all child contexts must be deleted first or moved to a different parent)
- Instance Impact: Instances belonging to the deleted context will no longer belong to any context (if instances exist only in the deleted context, they will be permanently deleted from the system).
- IS-Manager: Can delete any context without restrictions
- Infrastructure-Manager: Can delete any context without restrictions
- Context-Manager: Can delete contexts only if they are Context-Manager of the parent context
- Other Users: Cannot delete contexts (will receive authorization errors).
ResourceRegistryContextClient client = ResourceRegistryContextClientFactory.create(); Context contextToDelete = client.read(contextUuid); // Delete the context using the context object boolean deleted = client.delete(contextToDelete); if (deleted) { System.out.println("Context successfully deleted"); }- Parameters:
context- the context object to delete- Returns:
trueif the context was successfully deleted,falseotherwise- Throws:
org.gcube.informationsystem.resourceregistry.api.exceptions.contexts.ContextNotFoundException- if the context with the specified UUID is not foundorg.gcube.informationsystem.resourceregistry.api.exceptions.ResourceRegistryException- if the context cannot be deleted due to authorization issues, child contexts, or other errors
-
delete
boolean delete(UUID uuid) throws org.gcube.informationsystem.resourceregistry.api.exceptions.contexts.ContextNotFoundException, org.gcube.informationsystem.resourceregistry.api.exceptions.ResourceRegistryException Deletes an existing context permanently from the system using its UUID. Corresponding REST API:DELETE /contexts/{context-uuid}Operation Behavior:- Permanently deletes the context with the specified UUID from the system
- Context is moved to a "cemetery" for audit trails and historical tracking
- The UUID becomes permanently unavailable for reuse
- Once deleted, the context cannot be restored through normal operations.
- 200 OK: Context successfully deleted
- 404 Not Found: Context with the specified UUID is not found
- 409 Conflict: Context has child contexts or other dependencies preventing deletion
- 403 Forbidden: User lacks authorization to delete the context
- 401 Unauthorized: Invalid or missing authentication credentials.
- UUID must be a valid UUID format
- Context must exist and be accessible to the user
- Child Contexts: Cannot delete a context that has child contexts (all child contexts must be deleted first or moved to a different parent)
- Instance Impact: Instances belonging to the deleted context will no longer belong to any context (if instances exist only in the deleted context, they will be permanently deleted from the system).
- IS-Manager: Can delete any context without restrictions
- Infrastructure-Manager: Can delete any context without restrictions
- Context-Manager: Can delete contexts only if they are Context-Manager of the parent context
- Other Users: Cannot delete contexts (will receive authorization errors).
ResourceRegistryContextClient client = ResourceRegistryContextClientFactory.create(); UUID contextUuid = UUID.fromString("c0f314e7-2807-4241-a792-2a6c79ed4fd0"); // Delete the context using UUID boolean deleted = client.delete(contextUuid); if (deleted) { System.out.println("Context successfully deleted"); }- Parameters:
uuid- the UUID of the context to delete- Returns:
trueif the context was successfully deleted,falseotherwise- Throws:
org.gcube.informationsystem.resourceregistry.api.exceptions.contexts.ContextNotFoundException- if the context with the specified UUID is not foundorg.gcube.informationsystem.resourceregistry.api.exceptions.ResourceRegistryException- if the context cannot be deleted due to authorization issues, child contexts, or other errors
-
delete
boolean delete(String uuid) throws org.gcube.informationsystem.resourceregistry.api.exceptions.contexts.ContextNotFoundException, org.gcube.informationsystem.resourceregistry.api.exceptions.ResourceRegistryException Deletes an existing context permanently from the system using its UUID (as string). Corresponding REST API:DELETE /contexts/{context-uuid}Operation Behavior:- Converts the string UUID to a UUID object and delegates to
delete(UUID) - Permanently deletes the context with the specified UUID from the system
- Context is moved to a "cemetery" for audit trails and historical tracking
- The UUID becomes permanently unavailable for reuse.
- 200 OK: Context successfully deleted
- 404 Not Found: Context with the specified UUID is not found
- 409 Conflict: Context has child contexts or other dependencies preventing deletion
- 403 Forbidden: User lacks authorization to delete the context
- 401 Unauthorized: Invalid or missing authentication credentials.
- String must be a valid UUID format
- Context must exist and be accessible to the user
- Child Contexts: Cannot delete a context that has child contexts (all child contexts must be deleted first or moved to a different parent)
- Instance Impact: Instances belonging to the deleted context will no longer belong to any context (if instances exist only in the deleted context, they will be permanently deleted from the system).
- IS-Manager: Can delete any context without restrictions
- Infrastructure-Manager: Can delete any context without restrictions
- Context-Manager: Can delete contexts only if they are Context-Manager of the parent context
- Other Users: Cannot delete contexts (will receive authorization errors).
ResourceRegistryContextClient client = ResourceRegistryContextClientFactory.create(); String contextUuidString = "c0f314e7-2807-4241-a792-2a6c79ed4fd0"; // Delete the context using string UUID try { boolean deleted = client.delete(contextUuidString); if (deleted) { System.out.println("Context successfully deleted"); } } catch (IllegalArgumentException e) { System.err.println("Invalid UUID format: " + contextUuidString); }- Parameters:
uuid- the UUID of the context (as string) to delete- Returns:
trueif the context was successfully deleted,falseotherwise- Throws:
org.gcube.informationsystem.resourceregistry.api.exceptions.contexts.ContextNotFoundException- if the context with the specified UUID is not foundorg.gcube.informationsystem.resourceregistry.api.exceptions.ResourceRegistryException- if the context cannot be deleted due to authorization issues, child contexts, or other errorsIllegalArgumentException- if the provided string is not a valid UUID format
- Converts the string UUID to a UUID object and delegates to
-
changeState
org.gcube.informationsystem.contexts.reference.entities.Context changeState(org.gcube.informationsystem.contexts.reference.entities.Context context) throws org.gcube.informationsystem.resourceregistry.api.exceptions.contexts.ContextNotFoundException, org.gcube.informationsystem.resourceregistry.api.exceptions.ResourceRegistryException Changes the state of an existing context by extracting its UUID from the provided context object. This is a convenience method that delegates to the internal change state operation using the context's ID. Corresponding REST API:PATCH /contexts/{context-uuid}Operation Behavior:- State-Only Operation: Only the state property from the context object is evaluated and applied
- Property Isolation: All other properties in the context object are ignored during state change
- Complete Response: Returns the complete updated context with the new state and all other properties
- Extracts the UUID from the provided context object for identification.
- 200 OK: Context state successfully changed
- 404 Not Found: Context with the specified UUID is not found
- 400 Bad Request: Invalid state value or validation failure
- 403 Forbidden: User lacks authorization to change the context state
- 401 Unauthorized: Invalid or missing authentication credentials.
- Context object must contain a valid UUID for identification
- Context object must contain a valid state value
- State values must be valid according to the ContextState class
- All other properties in the context object are ignored and will not be modified.
- IS-Manager: Can change state of any context without restrictions
- Infrastructure-Manager: Can change state of any context without restrictions
- Context-Manager: Can change state of contexts only if they are Context-Manager of the parent context
- Other Users: Cannot change context states (will receive authorization errors).
ResourceRegistryContextClient client = ResourceRegistryContextClientFactory.create(); // Get context and change its state Context context = client.read(contextUuid); context.setState(ContextState.ACTIVE); // Set new state // Change the context state Context updatedContext = client.changeState(context); System.out.println("New state: " + updatedContext.getState()); // All other properties are preserved System.out.println("Context name unchanged: " + updatedContext.getName());- Parameters:
context- the context object containing the UUID and new state to apply- Returns:
- the complete Context object with the updated state and full metadata
- Throws:
org.gcube.informationsystem.resourceregistry.api.exceptions.contexts.ContextNotFoundException- if the context with the specified UUID is not foundorg.gcube.informationsystem.resourceregistry.api.exceptions.ResourceRegistryException- if the state cannot be changed due to authorization issues, invalid state, or other errors
-
changeState
String changeState(String context) throws org.gcube.informationsystem.resourceregistry.api.exceptions.contexts.ContextNotFoundException, org.gcube.informationsystem.resourceregistry.api.exceptions.ResourceRegistryException Changes the state of an existing context from its JSON representation. Corresponding REST API:PATCH /contexts/{context-uuid}Operation Behavior:- State-Only Operation: Only the state property from the JSON is evaluated and applied
- Property Isolation: All other properties in the JSON are ignored during state change
- Complete Response: Returns the complete updated context as JSON with the new state and all other properties
- Parses the JSON to extract UUID and state information.
- 200 OK: Context state successfully changed
- 404 Not Found: Context with the specified UUID is not found
- 400 Bad Request: Invalid JSON format, state value, or validation failure
- 403 Forbidden: User lacks authorization to change the context state
- 401 Unauthorized: Invalid or missing authentication credentials.
- JSON must contain a valid Context representation
- JSON must include a valid UUID field to identify the target context
- JSON must include a valid state field with the new state value
- State values must be valid according to the ContextState class
- All other JSON properties are ignored and will not be modified.
- IS-Manager: Can change state of any context without restrictions
- Infrastructure-Manager: Can change state of any context without restrictions
- Context-Manager: Can change state of contexts only if they are Context-Manager of the parent context
- Other Users: Cannot change context states (will receive authorization errors).
ResourceRegistryContextClient client = ResourceRegistryContextClientFactory.create(); // JSON with UUID and new state (other properties ignored) String contextJson = """ { "@class": "Context", "id": "c0f314e7-2807-4241-a792-2a6c79ed4fd0", "state": "ACTIVE", "name": "This will be ignored" } """; // Change the context state from JSON String updatedContextJson = client.changeState(contextJson); // Parse response to verify state change Context updatedContext = ElementMapper.unmarshal(Context.class, updatedContextJson); System.out.println("New state: " + updatedContext.getState());- Parameters:
context- the JSON string representation containing the context UUID and new state- Returns:
- the complete updated context as JSON string with the new state and full metadata
- Throws:
org.gcube.informationsystem.resourceregistry.api.exceptions.contexts.ContextNotFoundException- if the context with the specified UUID is not foundorg.gcube.informationsystem.resourceregistry.api.exceptions.ResourceRegistryException- if the state cannot be changed due to authorization issues, invalid state, invalid JSON, or other errors
-
changeState
org.gcube.informationsystem.contexts.reference.entities.Context changeState(UUID uuid, org.gcube.informationsystem.contexts.reference.ContextState state) throws org.gcube.informationsystem.resourceregistry.api.exceptions.contexts.ContextNotFoundException, org.gcube.informationsystem.resourceregistry.api.exceptions.ResourceRegistryException Changes the state of an existing context using its UUID and the desired state. Corresponding REST API:PATCH /contexts/{context-uuid}Operation Behavior:- State-Only Operation: Only the state property is evaluated and applied by the server
- Complete Response: Returns the complete updated context with the new state and all other properties
- Type Safety: Uses ContextState enum instead of string, preventing invalid state values at compile time
- Simplicity: No need to construct a full context object or JSON string.
- 200 OK: Context state successfully changed
- 404 Not Found: Context with the specified UUID is not found
- 400 Bad Request: Invalid state value or validation failure
- 403 Forbidden: User lacks authorization to change the context state
- 401 Unauthorized: Invalid or missing authentication credentials.
- UUID must be a valid UUID format
- State values must be valid according to the ContextState enum
- Context must exist and be accessible to the user.
- IS-Manager: Can change state of any context without restrictions
- Infrastructure-Manager: Can change state of any context without restrictions
- Context-Manager: Can change state of contexts only if they are Context-Manager of the parent context
- Other Users: Cannot change context states (will receive authorization errors).
ResourceRegistryContextClient client = ResourceRegistryContextClientFactory.create(); UUID contextUuid = UUID.fromString("c0f314e7-2807-4241-a792-2a6c79ed4fd0"); // Change context state directly Context updatedContext = client.changeState(contextUuid, ContextState.ACTIVE); System.out.println("New state: " + updatedContext.getState()); // All other properties are preserved System.out.println("Context name unchanged: " + updatedContext.getName()); // Example with different states client.changeState(contextUuid, ContextState.INACTIVE); client.changeState(contextUuid, ContextState.READY);- Parameters:
uuid- the UUID of the context whose state should be changedstate- the new state to apply to the context- Returns:
- the complete Context object with the updated state and full metadata
- Throws:
org.gcube.informationsystem.resourceregistry.api.exceptions.contexts.ContextNotFoundException- if the context with the specified UUID is not foundorg.gcube.informationsystem.resourceregistry.api.exceptions.ResourceRegistryException- if the state cannot be changed due to authorization issues, invalid state, or other errors
-
changeState
String changeState(String uuid, String state) throws org.gcube.informationsystem.resourceregistry.api.exceptions.contexts.ContextNotFoundException, org.gcube.informationsystem.resourceregistry.api.exceptions.ResourceRegistryException Changes the state of an existing context using its UUID (as string) and the desired state (as string). This method provides string-based parameters for scenarios where enum types are not available or preferred. Corresponding REST API:PATCH /contexts/{context-uuid}Operation Behavior:- State-Only Operation: Only the state property is evaluated and applied by the server
- Complete Response: Returns the complete updated context as JSON with the new state and all other properties
- Converts string parameters to appropriate types and delegates to internal change state operation.
- 200 OK: Context state successfully changed
- 404 Not Found: Context with the specified UUID is not found
- 400 Bad Request: Invalid UUID format, state value, or validation failure
- 403 Forbidden: User lacks authorization to change the context state
- 401 Unauthorized: Invalid or missing authentication credentials.
- UUID string must be a valid UUID format
- State strings must correspond to valid ContextState enum values
- Context must exist and be accessible to the user.
- IS-Manager: Can change state of any context without restrictions
- Infrastructure-Manager: Can change state of any context without restrictions
- Context-Manager: Can change state of contexts only if they are Context-Manager of the parent context
- Other Users: Cannot change context states (will receive authorization errors).
ResourceRegistryContextClient client = ResourceRegistryContextClientFactory.create(); String contextUuidString = "c0f314e7-2807-4241-a792-2a6c79ed4fd0"; // Change context state using strings String updatedContextJson = client.changeState(contextUuidString, "ACTIVE"); // Parse response to verify state change Context updatedContext = ElementMapper.unmarshal(Context.class, updatedContextJson); System.out.println("New state: " + updatedContext.getState()); // Example with different states client.changeState(contextUuidString, "INACTIVE"); client.changeState(contextUuidString, "READY"); // Error handling for invalid inputs try { client.changeState("invalid-uuid", "ACTIVE"); } catch (IllegalArgumentException e) { System.err.println("Invalid UUID format"); } try { client.changeState(contextUuidString, "INVALID_STATE"); } catch (ResourceRegistryException e) { System.err.println("Invalid state value"); }- Parameters:
uuid- the UUID of the context (as string) whose state should be changedstate- the new state (as string) to apply to the context- Returns:
- the complete updated context as JSON string with the new state and full metadata
- Throws:
org.gcube.informationsystem.resourceregistry.api.exceptions.contexts.ContextNotFoundException- if the context with the specified UUID is not foundorg.gcube.informationsystem.resourceregistry.api.exceptions.ResourceRegistryException- if the state cannot be changed due to authorization issues, invalid state, or other errorsIllegalArgumentException- if the provided UUID string is not a valid UUID format or if the state string is not a valid ContextState value
-