Class ResourceRegistryContextClientImpl
- All Implemented Interfaces:
org.gcube.informationsystem.resourceregistry.api.request.RequestInfo,ResourceRegistryContextClient
ResourceRegistryContextClient, backed by HTTP calls to the
Resource Registry service and a local ContextCache used to serve reads without a
round-trip whenever possible.- Author:
- Luca Frosini (ISTI - CNR)
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected final StringThe base address of the Resource Registry serviceprotected org.gcube.informationsystem.resourceregistry.api.contexts.ContextCacheCache for context information to improve performanceprotected org.gcube.informationsystem.resourceregistry.api.contexts.ContextCacheRenewalContext cache renewal strategy for refreshing cached context informationHTTP headers to be included in requestsFields inherited from class org.gcube.informationsystem.resourceregistry.api.request.BaseRequestInfo
allMeta, hierarchicalMode, includeContexts, includeMeta, limit, offsetFields inherited from interface org.gcube.informationsystem.resourceregistry.api.request.RequestInfo
DEFAULT_LIMIT, DEFAULT_OFFSET, UNBOUNDED_LIMIT -
Constructor Summary
ConstructorsConstructorDescriptionResourceRegistryContextClientImpl(String address) This client does not use the shared context cache because it is used by managers to manipulate contexts. -
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 all live Contexts through the local cache.List<org.gcube.informationsystem.contexts.reference.entities.Context>all(org.gcube.informationsystem.resourceregistry.api.rest.ContextLifecycle lifecycle) Retrieves a page of Contexts from the server for the requested lifecycle slice, bypassing the local Context cache.changeState(String context) JSON-string counterpart ofResourceRegistryContextClient.changeState(Context).changeState(String uuid, String state) String-based counterpart ofResourceRegistryContextClient.changeState(UUID, ContextState).org.gcube.informationsystem.contexts.reference.entities.ContextchangeState(UUID uuid, org.gcube.informationsystem.contexts.reference.ContextState state) Changes only the state of an existing context, identified by UUID, sending a minimal merge-patch body ({"state": ...}) that cannot affectnameorparent.org.gcube.informationsystem.contexts.reference.entities.ContextchangeState(org.gcube.informationsystem.contexts.reference.entities.Context context) Changes only the state of an existing Context, extracting its UUID and state from the supplied object.Creates a Context from a JSON document supplied through the Java API as aString.org.gcube.informationsystem.contexts.reference.entities.Contextcreate(org.gcube.informationsystem.contexts.reference.entities.Context context) Creates a Context throughPUT /contexts/{context-uuid}.booleanParsesuuidand delegates toResourceRegistryContextClient.delete(UUID)without changing its logical-deletion, authorization, cache, retry, or response-metadata semantics.booleanLogically deletes a live Context, removing it from the active topology while retaining its state and history in the cemetery.booleandelete(org.gcube.informationsystem.contexts.reference.entities.Context context) Extracts the Context identifier and delegates toResourceRegistryContextClient.delete(UUID)without changing its logical-deletion, authorization, cache, or response-metadata semantics.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.booleanexistFromServer(String uuid) Checks if a context with the specified UUID exists on the server, via a directHEAD /contexts/{uuid}request (the local cache is not consulted).List<org.gcube.informationsystem.contexts.reference.entities.Context>It reads all the contexts from server.protected List<org.gcube.informationsystem.contexts.reference.entities.Context>getAllContextFromServer(boolean includeMeta, Integer offset, Integer limit) Retrieves all contexts from the Resource Registry server with specified parameters.protected List<org.gcube.informationsystem.contexts.reference.entities.Context>getAllContextFromServer(boolean includeMeta, Integer offset, Integer limit, org.gcube.informationsystem.resourceregistry.api.rest.ContextLifecycle lifecycle) Retrieves Contexts directly from the Resource Registry server for the requested lifecycle.protected List<org.gcube.informationsystem.contexts.reference.entities.Context>Retrieves every live Context from the paginated server endpoint for cache renewal.Returns the authentication headers supplied by the active secret provider.org.gcube.informationsystem.resourceregistry.api.contexts.ContextCacheGets the context cache used for context-related operations.protected org.gcube.common.gxhttp.request.GXHTTPStringRequestCreates and configures a GXHTTPStringRequest with authentication headers.protected StringinternalChangeState(UUID uuid, String context) Internal method to change the state of an existing context in the Resource Registry.protected StringinternalCreate(org.gcube.informationsystem.contexts.reference.entities.Context context) Internal method to create a new context in the Resource Registry.protected StringinternalTrackedUpdate(UUID uuid, String mergePatchJson) Sends a Tracked Update merge-patch to the server for the given context, and refreshes the local cache afterwards.internalUpdate(org.gcube.informationsystem.contexts.reference.entities.Context context) Internal method to apply a Tracked Update to an existing context in the Resource Registry.List<org.gcube.informationsystem.contexts.reference.entities.Context>Executes a JSON Query-By-Example against live Contexts.List<org.gcube.informationsystem.contexts.reference.entities.Context>query(String jsonQuery, org.gcube.informationsystem.resourceregistry.api.rest.ContextLifecycle lifecycle) Executes a JSON Query-By-Example against Contexts, restricted to the given lifecycle slice.Parses the UUID, delegates toResourceRegistryContextClient.read(UUID), and serializes the resulting Context hierarchy.Parses the UUID, delegates toResourceRegistryContextClient.read(UUID, int), and serializes the resulting Context hierarchy.org.gcube.informationsystem.contexts.reference.entities.ContextRetrieves a Context by UUID with root-only depth.org.gcube.informationsystem.contexts.reference.entities.ContextRetrieves a Context by UUID and expands descendants to the requested depth.org.gcube.informationsystem.contexts.reference.entities.Contextread(org.gcube.informationsystem.contexts.reference.entities.Context context) Retrieves a Context by delegating its identifier toResourceRegistryContextClient.read(UUID).org.gcube.informationsystem.contexts.reference.entities.Contextread(org.gcube.informationsystem.contexts.reference.entities.Context context, int depth) Retrieves a Context by delegating its identifier anddepthtoResourceRegistryContextClient.read(UUID, int).org.gcube.informationsystem.contexts.reference.entities.ContextRetrieves the Context associated with the authorization token using root-only depth.org.gcube.informationsystem.contexts.reference.entities.ContextreadCurrentContext(int depth) Retrieves the Context resolved by the server from the authorization token and expands descendants to the requested depth.readFromServer(String uuid) Reads a context from the server by its UUID.readFromServer(String uuid, int depth) Reads a context from the server by its UUID, expanding its descendant hierarchy to the given depth.List<org.gcube.informationsystem.model.reference.properties.Event>readHistory(String uuid) Parsesuuidand delegates toResourceRegistryContextClient.readHistory(UUID)without changing its history, authorization, or response-metadata semantics.List<org.gcube.informationsystem.model.reference.properties.Event>readHistory(UUID uuid) Retrieves the complete audit trail of a Context in reverse-chronological order, with the newestEventfirst.Full-Context JSON counterpart ofResourceRegistryContextClient.update(Context).Applies an RFC 7396 merge patch to the Context identified byuuid.org.gcube.informationsystem.contexts.reference.entities.Contextupdate(org.gcube.informationsystem.contexts.reference.entities.Context context) Performs a Tracked Update of an existing context:state,name, andparent(as carried by the given object's getters) are sent to the server and applied atomically.Methods inherited from class org.gcube.informationsystem.resourceregistry.api.request.BaseRequestInfo
allMeta, getLimit, getOffset, includeContexts, includeMeta, isHierarchicalMode, setAllMeta, setHierarchicalMode, setIncludeContexts, setIncludeMeta, setLimit, setOffsetMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface org.gcube.informationsystem.resourceregistry.api.request.RequestInfo
allMeta, getLimit, getOffset, includeContexts, includeMeta, isHierarchicalMode, serverResponses, setAllMeta, setHierarchicalMode, setIncludeContexts, setIncludeMeta, setLimit, setOffset
-
Field Details
-
address
The base address of the Resource Registry service -
headers
HTTP headers to be included in requests -
contextCache
protected org.gcube.informationsystem.resourceregistry.api.contexts.ContextCache contextCacheCache for context information to improve performance -
contextCacheRenewal
protected org.gcube.informationsystem.resourceregistry.api.contexts.ContextCacheRenewal contextCacheRenewalContext cache renewal strategy for refreshing cached context information
-
-
Constructor Details
-
ResourceRegistryContextClientImpl
This client does not use the shared context cache because it is used by managers to manipulate contexts. The shared cache has only minimal context information available to any users.- Parameters:
address- The base address of the Resource Registry service
-
-
Method Details
-
getAllLiveContextsFromServer
protected List<org.gcube.informationsystem.contexts.reference.entities.Context> getAllLiveContextsFromServer() throws org.gcube.informationsystem.resourceregistry.api.exceptions.ResourceRegistryExceptionRetrieves every live Context from the paginated server endpoint for cache renewal.- Returns:
- complete live Context collection
- Throws:
org.gcube.informationsystem.resourceregistry.api.exceptions.ResourceRegistryException- if any page cannot be retrieved
-
addHeader
Adds a custom HTTP header to be included in requests.Invocation-specific options and immutable response metadata are available through
RequestInfo.serverResponses().- Specified by:
addHeaderin interfaceResourceRegistryContextClient- Parameters:
name- Header namevalue- Header value
-
addHeader
Adds a custom HTTP header to be included in requests.Invocation-specific options and immutable response metadata are available through
RequestInfo.serverResponses().- Specified by:
addHeaderin interfaceResourceRegistryContextClient- Parameters:
name- Header namevalue- boolean value
-
getGXHTTPStringRequest
protected org.gcube.common.gxhttp.request.GXHTTPStringRequest getGXHTTPStringRequest()Creates and configures a GXHTTPStringRequest with authentication headers.- Returns:
- A configured GXHTTPStringRequest instance ready for making HTTP requests
-
getAuthorizationHeaders
Returns the authentication headers supplied by the active secret provider.- Returns:
- authentication headers for the current invocation
-
getAllContextFromServer
public List<org.gcube.informationsystem.contexts.reference.entities.Context> getAllContextFromServer() throws org.gcube.informationsystem.resourceregistry.api.exceptions.ResourceRegistryExceptionIt reads all the contexts from server. The cache used for contexts is bypassed and not updated.- Returns:
- All Contexts read from server
- Throws:
org.gcube.informationsystem.resourceregistry.api.exceptions.ResourceRegistryException- If an error occurs during the operation
-
getAllContextFromServer
protected List<org.gcube.informationsystem.contexts.reference.entities.Context> getAllContextFromServer(boolean includeMeta, Integer offset, Integer limit) throws org.gcube.informationsystem.resourceregistry.api.exceptions.ResourceRegistryException Retrieves all contexts from the Resource Registry server with specified parameters.- Parameters:
includeMeta- Whether to include metadata in the responseoffset- The offset for paginationlimit- The limit for pagination- Returns:
- List of all contexts from the server
- Throws:
org.gcube.informationsystem.resourceregistry.api.exceptions.ResourceRegistryException- If an error occurs during the operation
-
getAllContextFromServer
protected List<org.gcube.informationsystem.contexts.reference.entities.Context> getAllContextFromServer(boolean includeMeta, Integer offset, Integer limit, org.gcube.informationsystem.resourceregistry.api.rest.ContextLifecycle lifecycle) throws org.gcube.informationsystem.resourceregistry.api.exceptions.ResourceRegistryException Retrieves Contexts directly from the Resource Registry server for the requested lifecycle.- Parameters:
includeMeta- whether metadata is included in the responseoffset- starting position for paginationlimit- maximum number of Contexts to returnlifecycle- lifecycle slice to retrieve, ornullfor the server default- Returns:
- Contexts returned by the server
- Throws:
org.gcube.informationsystem.resourceregistry.api.exceptions.ResourceRegistryException- if retrieval fails
-
all
public List<org.gcube.informationsystem.contexts.reference.entities.Context> all() throws org.gcube.informationsystem.resourceregistry.api.exceptions.ResourceRegistryExceptionRetrieves all live Contexts through the local cache.Invocation-specific List options force a server-backed request so that pagination, metadata policy, lifecycle selection, and response metadata remain observable. Use
ResourceRegistryContextClient.all(ContextLifecycle)for an explicit lifecycle selection.- Specified by:
allin interfaceResourceRegistryContextClient- Returns:
- all cached live Contexts, or the effective server page when request options are active
- Throws:
org.gcube.informationsystem.resourceregistry.api.exceptions.ResourceRegistryException- if retrieval fails or the caller is not authorized
-
all
public List<org.gcube.informationsystem.contexts.reference.entities.Context> all(org.gcube.informationsystem.resourceregistry.api.rest.ContextLifecycle lifecycle) throws org.gcube.informationsystem.resourceregistry.api.exceptions.ResourceRegistryException Retrieves a page of Contexts from the server for the requested lifecycle slice, bypassing the local Context cache.A
nulllifecycle omits the wire-levellifecyclequery parameter and uses the server default (live). Valuesdeletedandallrequire an IS-Manager or Infrastructure-Manager role and otherwise produce an authorization error. Pagination and metadata settings come from this client, while invocation-specific options supplied throughRequestInfo.serverResponses()take precedence.- Specified by:
allin interfaceResourceRegistryContextClient- Parameters:
lifecycle- lifecycle slice to retrieve, ornullfor the server default- Returns:
- Contexts in the requested lifecycle slice for the effective page
- Throws:
org.gcube.informationsystem.resourceregistry.api.exceptions.ResourceRegistryException- if retrieval fails or the caller cannot request the lifecycle
-
getContextCache
public org.gcube.informationsystem.resourceregistry.api.contexts.ContextCache getContextCache()Gets the context cache used for context-related operations.Invocation-specific options and immutable response metadata are available through
RequestInfo.serverResponses().- Specified by:
getContextCachein interfaceResourceRegistryContextClient- Returns:
- The context cache instance
-
query
public List<org.gcube.informationsystem.contexts.reference.entities.Context> query(String jsonQuery) throws org.gcube.informationsystem.resourceregistry.api.exceptions.queries.InvalidQueryException, org.gcube.informationsystem.resourceregistry.api.exceptions.ResourceRegistryException Executes a JSON Query-By-Example against live Contexts. Equivalent toResourceRegistryContextClient.query(String, ContextLifecycle)with anulllifecycle (server default: live contexts only).Invocation-specific options and immutable response metadata are available through
RequestInfo.serverResponses().- Specified by:
queryin interfaceResourceRegistryContextClient- Parameters:
jsonQuery- the JSON Query-By-Example payload- Returns:
- the matching Context objects
- Throws:
org.gcube.informationsystem.resourceregistry.api.exceptions.queries.InvalidQueryException- if the query syntax is invalidorg.gcube.informationsystem.resourceregistry.api.exceptions.ResourceRegistryException- if the query cannot be executed due to authorization issues or other errors
-
query
public List<org.gcube.informationsystem.contexts.reference.entities.Context> query(String jsonQuery, org.gcube.informationsystem.resourceregistry.api.rest.ContextLifecycle lifecycle) throws org.gcube.informationsystem.resourceregistry.api.exceptions.queries.InvalidQueryException, org.gcube.informationsystem.resourceregistry.api.exceptions.ResourceRegistryException Executes a JSON Query-By-Example against Contexts, restricted to the given lifecycle slice.Invocation-specific options and immutable response metadata are available through
RequestInfo.serverResponses().Implemented as
POST /contexts/querywith theX-HTTP-Method-Override: QUERYheader, since the underlying HTTP client does not support issuing a realQUERYrequest.- Specified by:
queryin interfaceResourceRegistryContextClient- Parameters:
jsonQuery- the JSON Query-By-Example payloadlifecycle- the Context lifecycle slice to search (nullfor the server default,live);deletedandallare restricted to IS-Manager / Infrastructure-Manager- Returns:
- the matching Context objects
- Throws:
org.gcube.informationsystem.resourceregistry.api.exceptions.queries.InvalidQueryException- if the query syntax is invalidorg.gcube.informationsystem.resourceregistry.api.exceptions.ResourceRegistryException- if the query cannot be executed due to authorization issues or other errors
-
internalCreate
protected String internalCreate(org.gcube.informationsystem.contexts.reference.entities.Context context) throws org.gcube.informationsystem.resourceregistry.api.exceptions.contexts.ContextAlreadyPresentException, org.gcube.informationsystem.resourceregistry.api.exceptions.ResourceRegistryException Internal method to create a new context in the Resource Registry. Handles UUID generation if not present and marshals the context to JSON.- Parameters:
context- The context to create- Returns:
- The JSON representation of the created context
- Throws:
org.gcube.informationsystem.resourceregistry.api.exceptions.contexts.ContextAlreadyPresentException- If a context with the same UUID already existsorg.gcube.informationsystem.resourceregistry.api.exceptions.ResourceRegistryException- If an error occurs during creation
-
create
public 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 Context throughPUT /contexts/{context-uuid}. A UUID is generated and assigned to the supplied object when absent. Repeating a congruent representation is an idempotent success; an incongruent representation for an existing UUID is rejected.The caller must use an administrative token for the immediate parent Context. Root creation requires an IS-Manager or Infrastructure-Manager token for the exact Root path. Request options, including
metadataPolicy, and immutable response status, headers, and body are available through the invocation context andRequestInfo.serverResponses(). SuppliedstateandpreviousPathsvalues are ignored with a warning; historical paths are administered byResourceRegistryContextClient.update(UUID, String).- Specified by:
createin interfaceResourceRegistryContextClient- Parameters:
context- the Context to create- Returns:
- the server representation of the created or congruent existing Context
- Throws:
org.gcube.informationsystem.resourceregistry.api.exceptions.contexts.ContextAlreadyPresentException- if the UUID exists with an incongruent representationorg.gcube.informationsystem.resourceregistry.api.exceptions.ResourceRegistryException- if serialization, transport, validation, or authorization fails- See Also:
-
create
public String create(String context) throws org.gcube.informationsystem.resourceregistry.api.exceptions.contexts.ContextAlreadyPresentException, org.gcube.informationsystem.resourceregistry.api.exceptions.ResourceRegistryException Creates a Context from a JSON document supplied through the Java API as aString. The document is decoded locally, assigned a UUID when absent, and sent as an object-valued JSON body throughPUT /contexts/{context-uuid}.Authorization, idempotency, request-option, and response-metadata behavior is identical to
ResourceRegistryContextClient.create(Context).- Specified by:
createin interfaceResourceRegistryContextClient- Parameters:
context- the object-valued JSON document represented as a Java string- Returns:
- the server JSON representation of the created or congruent existing Context
- Throws:
org.gcube.informationsystem.resourceregistry.api.exceptions.contexts.ContextAlreadyPresentException- if the UUID exists with an incongruent representationorg.gcube.informationsystem.resourceregistry.api.exceptions.ResourceRegistryException- if decoding, serialization, transport, validation, or authorization fails- See Also:
-
existFromServer
public boolean existFromServer(String uuid) throws org.gcube.informationsystem.resourceregistry.api.exceptions.contexts.ContextNotFoundException, org.gcube.informationsystem.resourceregistry.api.exceptions.ResourceRegistryException Checks if a context with the specified UUID exists on the server, via a directHEAD /contexts/{uuid}request (the local cache is not consulted).- Parameters:
uuid- The UUID of the context to check- Returns:
- true if the context exists, false otherwise
- Throws:
org.gcube.informationsystem.resourceregistry.api.exceptions.contexts.ContextNotFoundException- declared for signature symmetry with the rest of this class, but never actually thrown by this method: a 404 response is caught asNotFoundException(its supertype) and translated into afalsereturn value rather than being propagatedorg.gcube.informationsystem.resourceregistry.api.exceptions.ResourceRegistryException- If an error occurs during the operation
-
exist
public 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.Invocation-specific options and immutable response metadata are available through
Implementation Details: UUID Conversion:RequestInfo.serverResponses().- Converts the string UUID to
UUIDobject usingUUID.fromString() - Delegates to
exist(UUID)for the actual existence check
- Will throw
IllegalArgumentExceptionif the string is not a valid UUID format - Other exceptions are handled by the delegated
exist(UUID)method
- Specified by:
existin interfaceResourceRegistryContextClient- 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 service
- Converts the string UUID to
-
exist
public boolean exist(UUID uuid) throws org.gcube.informationsystem.resourceregistry.api.exceptions.ResourceRegistryException Checks if a context with the specified UUID exists in the system.Invocation-specific options and immutable response metadata are available through
Implementation Details: Cache-First Strategy:RequestInfo.serverResponses().- Uses
read(UUID)method to check existence - Leverages the cache-first approach of the read operation for performance
- If context exists in cache, no server call is made (very fast)
- If not in cache, makes REST API call via
readFromServer()
- Returns
trueifread(UUID)succeeds - Returns
falseifread(UUID)throwsContextNotFoundException - Propagates other
ResourceRegistryExceptiontypes
- Very Fast: When context is in cache (no server call)
- Moderate: When cache miss occurs (requires server round-trip via read)
- Returns
falsefor contexts that exist but are not accessible to the current user - This is because the underlying
read()operation will fail with authorization errors - Effectively combines existence and accessibility checking
- Specified by:
existin interfaceResourceRegistryContextClient- 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
- Uses
-
read
public 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 delegating its identifier toResourceRegistryContextClient.read(UUID).- Specified by:
readin interfaceResourceRegistryContextClient- 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
public org.gcube.informationsystem.contexts.reference.entities.Context read(org.gcube.informationsystem.contexts.reference.entities.Context context, int depth) throws org.gcube.informationsystem.resourceregistry.api.exceptions.contexts.ContextNotFoundException, org.gcube.informationsystem.resourceregistry.api.exceptions.ResourceRegistryException Retrieves a Context by delegating its identifier anddepthtoResourceRegistryContextClient.read(UUID, int).- Specified by:
readin interfaceResourceRegistryContextClient- Parameters:
context- the context object containing the UUID to retrievedepth-ContextPath.DEPTH_ROOT_ONLYfor the context alone, a positive integer for that many levels of descendants, orContextPath.DEPTH_UNLIMITEDfor the full subtree- Returns:
- the Context object, with
childrenpopulated according todepth - 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
public 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 Context by UUID with root-only depth. This is equivalent toResourceRegistryContextClient.read(UUID, int)withContextPath.DEPTH_ROOT_ONLY.When no invocation options are active, a matching local cache entry may satisfy the call. An explicit metadata policy, depth, or custom request setting forces a server request so the option and response metadata remain observable through
RequestInfo.serverResponses().- Specified by:
readin interfaceResourceRegistryContextClient- 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
public org.gcube.informationsystem.contexts.reference.entities.Context read(UUID uuid, int depth) throws org.gcube.informationsystem.resourceregistry.api.exceptions.contexts.ContextNotFoundException, org.gcube.informationsystem.resourceregistry.api.exceptions.ResourceRegistryException Retrieves a Context by UUID and expands descendants to the requested depth. The server's flat result is returned as one rooted Context hierarchy; child summaries beyond the requested depth remain summaries.Invocation-specific options and immutable response metadata are available through
RequestInfo.serverResponses(). ThemetadataPolicyanddepthrequest options map to the corresponding query parameters and take precedence for that invocation. If authorization resolves the token through a retained previous path, the response metadata exposesX-Result-Scope: previous-pathandX-Resolved-Context-Path.Depth-expanded reads always bypass the cache (which only holds flat, depth-0 context representations) and go straight to the server.
- Specified by:
readin interfaceResourceRegistryContextClient- Parameters:
uuid- the UUID of the context to retrievedepth-ContextPath.DEPTH_ROOT_ONLYfor the context alone, a positive integer for that many levels of descendants, orContextPath.DEPTH_UNLIMITEDfor the full subtree- Returns:
- the Context object, with
childrenpopulated according todepth - 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 communication, deserialization, or authorization fails; direct reads require a self token, except that administrative callers may use an ancestor token
-
readCurrentContext
public 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 Context associated with the authorization token using root-only depth. This is equivalent toResourceRegistryContextClient.readCurrentContext(int)withContextPath.DEPTH_ROOT_ONLY.- Specified by:
readCurrentContextin interfaceResourceRegistryContextClient- 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
-
readCurrentContext
public org.gcube.informationsystem.contexts.reference.entities.Context readCurrentContext(int depth) throws org.gcube.informationsystem.resourceregistry.api.exceptions.contexts.ContextNotFoundException, org.gcube.informationsystem.resourceregistry.api.exceptions.ResourceRegistryException Retrieves the Context resolved by the server from the authorization token and expands descendants to the requested depth. This operation always uses the server so token-resolution outcomes and response metadata remain authoritative.The
depthandmetadataPolicyrequest options map to the corresponding query parameters and take precedence for that invocation. Response warnings, links, and canonical content location are available throughRequestInfo.serverResponses(). When the token path matches a retained previous path, the response metadata containsX-Result-Scope: previous-pathandX-Resolved-Context-Pathwith the current path.- Specified by:
readCurrentContextin interfaceResourceRegistryContextClient- Parameters:
depth-ContextPath.DEPTH_ROOT_ONLYfor the context alone, a positive integer for that many levels of descendants, orContextPath.DEPTH_UNLIMITEDfor the full subtree- Returns:
- the Context object, with
childrenpopulated according todepth - Throws:
org.gcube.informationsystem.resourceregistry.api.exceptions.contexts.ContextNotFoundException- if the token path resolves to no live or deleted Contextorg.gcube.informationsystem.resourceregistry.api.exceptions.ResourceRegistryException- if communication, deserialization, or authorization fails; non-manager access to a deleted token Context is rejected
-
read
public String read(String uuid) throws org.gcube.informationsystem.resourceregistry.api.exceptions.contexts.ContextNotFoundException, org.gcube.informationsystem.resourceregistry.api.exceptions.ResourceRegistryException Parses the UUID, delegates toResourceRegistryContextClient.read(UUID), and serializes the resulting Context hierarchy.- Specified by:
readin interfaceResourceRegistryContextClient- 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 issues
-
read
public String read(String uuid, int depth) throws org.gcube.informationsystem.resourceregistry.api.exceptions.contexts.ContextNotFoundException, org.gcube.informationsystem.resourceregistry.api.exceptions.ResourceRegistryException Parses the UUID, delegates toResourceRegistryContextClient.read(UUID, int), and serializes the resulting Context hierarchy.- Specified by:
readin interfaceResourceRegistryContextClient- Parameters:
uuid- the UUID of the context (as string) to retrievedepth-ContextPath.DEPTH_ROOT_ONLYfor the context alone, a positive integer for that many levels of descendants, orContextPath.DEPTH_UNLIMITEDfor the full subtree- Returns:
- the Context as JSON string, with
childrenpopulated according todepth - 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
-
readFromServer
public String readFromServer(String uuid) throws org.gcube.informationsystem.resourceregistry.api.exceptions.contexts.ContextNotFoundException, org.gcube.informationsystem.resourceregistry.api.exceptions.ResourceRegistryException Reads a context from the server by its UUID.- Parameters:
uuid- The UUID of the context to read- Returns:
- The JSON representation of the context
- 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 an error occurs during the operation
-
readFromServer
public String readFromServer(String uuid, int depth) throws org.gcube.informationsystem.resourceregistry.api.exceptions.contexts.ContextNotFoundException, org.gcube.informationsystem.resourceregistry.api.exceptions.ResourceRegistryException Reads a context from the server by its UUID, expanding its descendant hierarchy to the given depth.- Parameters:
uuid- The UUID of the context to readdepth- the hierarchy expansion depth (ContextPath.DEPTH_ROOT_ONLY, a positive integer, orContextPath.DEPTH_UNLIMITED)- Returns:
- The JSON representation of the context
- 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 an error occurs during the operation
-
internalTrackedUpdate
protected String internalTrackedUpdate(UUID uuid, String mergePatchJson) throws org.gcube.informationsystem.resourceregistry.api.exceptions.contexts.ContextNotFoundException, org.gcube.informationsystem.resourceregistry.api.exceptions.ResourceRegistryException Sends a Tracked Update merge-patch to the server for the given context, and refreshes the local cache afterwards.- Parameters:
uuid- the UUID of the context to updatemergePatchJson- theapplication/merge-patch+jsonbody carrying the tracked fields to change- Returns:
- the JSON representation of the updated context
- 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 update is rejected or fails for another reason
-
internalUpdate
public String internalUpdate(org.gcube.informationsystem.contexts.reference.entities.Context context) throws org.gcube.informationsystem.resourceregistry.api.exceptions.contexts.ContextNotFoundException, org.gcube.informationsystem.resourceregistry.api.exceptions.ResourceRegistryException Internal method to apply a Tracked Update to an existing context in the Resource Registry. It builds a minimal patch containing onlystate,name, andparent; retainedpreviousPathsare never replaced implicitly by this full-object overload.- Parameters:
context- The context to update- Returns:
- The JSON representation of the updated context
- 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 an error occurs during the update
-
update
public 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 Performs a Tracked Update of an existing context:state,name, andparent(as carried by the given object's getters) are sent to the server and applied atomically. The object'spreviousPathsare deliberately omitted so a stale full representation cannot replace the server's retained set; useResourceRegistryContextClient.update(UUID, String)for an explicit replacement.Invocation-specific options and immutable response metadata are available through
RequestInfo.serverResponses(), including previous-path resolution headers when applicable.- Specified by:
updatein interfaceResourceRegistryContextClient- Parameters:
context- a Context object (typically obtained viaread()) carrying the UUID to update and the desiredstate/name/parent- 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 update is rejected (e.g. rename/reparent whileACTIVE) or fails due to authorization issues or other errors
-
update
public String update(UUID uuid, String mergePatchJson) throws org.gcube.informationsystem.resourceregistry.api.exceptions.contexts.ContextNotFoundException, org.gcube.informationsystem.resourceregistry.api.exceptions.ResourceRegistryException Applies an RFC 7396 merge patch to the Context identified byuuid. The Java API accepts the object-valued JSON document as aString; it is transmitted unchanged withContent-Type: application/merge-patch+json.The patch may contain
state,name,parent, andpreviousPaths. The latter is null or an array of absolute path strings and replaces the complete retained set. Other fields are ignored with a warning. Invocation-specific options and immutable response metadata, including warnings, links, content location, and previous-path resolution headers, are available throughRequestInfo.serverResponses().- Specified by:
updatein interfaceResourceRegistryContextClient- Parameters:
uuid- the UUID of the Context to updatemergePatchJson- the object-valued merge-patch document represented as a Java string- Returns:
- the complete updated Context representation as JSON
- Throws:
org.gcube.informationsystem.resourceregistry.api.exceptions.contexts.ContextNotFoundException- if the Context or requested new parent does not existorg.gcube.informationsystem.resourceregistry.api.exceptions.ResourceRegistryException- if decoding, transport, validation, authorization, or update fails
-
update
public String update(String context) throws org.gcube.informationsystem.resourceregistry.api.exceptions.contexts.ContextNotFoundException, org.gcube.informationsystem.resourceregistry.api.exceptions.ResourceRegistryException Full-Context JSON counterpart ofResourceRegistryContextClient.update(Context). The Java string is decoded as aContext; onlystate,name, andparentare sent. UseResourceRegistryContextClient.update(UUID, String)to replacepreviousPathsor preserve another arbitrary partial merge-patch document unchanged.Invocation-specific options and immutable response metadata are available through
RequestInfo.serverResponses().- Specified by:
updatein interfaceResourceRegistryContextClient- Parameters:
context- the JSON string representation of the context carrying the UUID and the desiredstate/name/parent- 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 update is rejected (e.g. rename/reparent whileACTIVE) or fails due to authorization issues, invalid JSON, or other errors
-
delete
public 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 Extracts the Context identifier and delegates toResourceRegistryContextClient.delete(UUID)without changing its logical-deletion, authorization, cache, or response-metadata semantics.- Specified by:
deletein interfaceResourceRegistryContextClient- Parameters:
context- the non-null Context whose non-null identifier selects the deletion target- Returns:
truewhen the server confirms logical deletion- 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 deletion is rejected or fails
-
delete
public boolean delete(UUID uuid) throws org.gcube.informationsystem.resourceregistry.api.exceptions.contexts.ContextNotFoundException, org.gcube.informationsystem.resourceregistry.api.exceptions.ResourceRegistryException Logically deletes a live Context, removing it from the active topology while retaining its state and history in the cemetery. A successful bodyless response returnstrue; this method never usesfalseto represent a server error.The caller must hold an administrative role with a token for the target's immediate parent, or for the target itself when deleting a Root Context. Deletion is rejected while the Context has children or graph instances. The operation supports no query options; unsupported raw query parameters are ignored with
X-Warning. The local cache is invalidated without issuing a follow-up request. Immutable status, warning, and request metadata are available throughRequestInfo.serverResponses(); this includes the two previous-path resolution headers when parent scope was established through a retained path.Deletion is effect-idempotent: retrying after success leaves the Context deleted but raises
ContextNotFoundException, because the UUID is no longer in the live topology.- Specified by:
deletein interfaceResourceRegistryContextClient- Parameters:
uuid- the non-null UUID of the live Context to delete- Returns:
truewhen the server confirms logical deletion- Throws:
org.gcube.informationsystem.resourceregistry.api.exceptions.contexts.ContextNotFoundException- if the UUID is unknown or already in the cemeteryorg.gcube.informationsystem.resourceregistry.api.exceptions.ResourceRegistryException- if authorization, a non-empty Context, transport, or another registry operation prevents deletion
-
delete
public boolean delete(String uuid) throws org.gcube.informationsystem.resourceregistry.api.exceptions.contexts.ContextNotFoundException, org.gcube.informationsystem.resourceregistry.api.exceptions.ResourceRegistryException Parsesuuidand delegates toResourceRegistryContextClient.delete(UUID)without changing its logical-deletion, authorization, cache, retry, or response-metadata semantics.- Specified by:
deletein interfaceResourceRegistryContextClient- Parameters:
uuid- the non-null textual UUID of the live Context to delete- Returns:
truewhen the server confirms logical deletion- Throws:
org.gcube.informationsystem.resourceregistry.api.exceptions.contexts.ContextNotFoundException- if the UUID is unknown or already in the cemeteryorg.gcube.informationsystem.resourceregistry.api.exceptions.ResourceRegistryException- if deletion is rejected or fails
-
readHistory
public List<org.gcube.informationsystem.model.reference.properties.Event> readHistory(UUID uuid) throws org.gcube.informationsystem.resourceregistry.api.exceptions.contexts.ContextNotFoundException, org.gcube.informationsystem.resourceregistry.api.exceptions.ResourceRegistryException Retrieves the complete audit trail of a Context in reverse-chronological order, with the newestEventfirst. A Context without recorded events produces an empty list.The caller must have an administrative role and use a token for the target Context or any ancestor. Only globally privileged roles can read deleted Context history. This operation has no query options; unsupported query parameters sent outside this typed API are ignored by the service with an
X-Warning. Immutable response metadata, including that warning and therel=uplink, is available throughRequestInfo.serverResponses(). The history includes independent additions, removals, cascades, and path-reuse collision events forpreviousPaths; previous-path token resolution is exposed through response headers.- Specified by:
readHistoryin interfaceResourceRegistryContextClient- Parameters:
uuid- the non-null UUID of the Context whose history to read- Returns:
- the complete reverse-chronological history, possibly empty
- 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 authorization, transport, response decoding, or another registry operation fails
-
readHistory
public List<org.gcube.informationsystem.model.reference.properties.Event> readHistory(String uuid) throws org.gcube.informationsystem.resourceregistry.api.exceptions.contexts.ContextNotFoundException, org.gcube.informationsystem.resourceregistry.api.exceptions.ResourceRegistryException Parsesuuidand delegates toResourceRegistryContextClient.readHistory(UUID)without changing its history, authorization, or response-metadata semantics.- Specified by:
readHistoryin interfaceResourceRegistryContextClient- Parameters:
uuid- the non-null textual UUID of the Context whose history to read- Returns:
- the complete reverse-chronological history, possibly empty
- 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 authorization, transport, response decoding, or another registry operation fails
-
internalChangeState
protected String internalChangeState(UUID uuid, String context) throws org.gcube.informationsystem.resourceregistry.api.exceptions.contexts.ContextNotFoundException, org.gcube.informationsystem.resourceregistry.api.exceptions.ResourceRegistryException Internal method to change the state of an existing context in the Resource Registry. Delegates the actual wire mechanics tointernalTrackedUpdate(UUID, String).- Parameters:
uuid- the UUID of the context whose state will be changedcontext- the merge-patch body carrying the new context state- Returns:
- the updated context as a JSON string
- Throws:
org.gcube.informationsystem.resourceregistry.api.exceptions.contexts.ContextNotFoundException- if the specified context UUID does not existorg.gcube.informationsystem.resourceregistry.api.exceptions.ResourceRegistryException- if an error occurs during the state change operation
-
changeState
public 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 only the state of an existing Context, extracting its UUID and state from the supplied object. The client sends a minimal merge patch, so the object's name and parent cannot be modified by this method.Invocation-specific options and immutable response metadata are available through
RequestInfo.serverResponses().- Specified by:
changeStatein interfaceResourceRegistryContextClient- Parameters:
context- the context object containing the UUID and the 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
public String changeState(String context) throws org.gcube.informationsystem.resourceregistry.api.exceptions.contexts.ContextNotFoundException, org.gcube.informationsystem.resourceregistry.api.exceptions.ResourceRegistryException JSON-string counterpart ofResourceRegistryContextClient.changeState(Context). The Java string is decoded locally to obtain the UUID and state; the client sends only the resulting minimal state merge patch.Invocation-specific options and immutable response metadata are available through
RequestInfo.serverResponses().- Specified by:
changeStatein interfaceResourceRegistryContextClient- 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
public 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 only the state of an existing context, identified by UUID, sending a minimal merge-patch body ({"state": ...}) that cannot affectnameorparent.Invocation-specific options and immutable response metadata are available through
RequestInfo.serverResponses().- Specified by:
changeStatein interfaceResourceRegistryContextClient- 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
public String changeState(String uuid, String state) throws org.gcube.informationsystem.resourceregistry.api.exceptions.contexts.ContextNotFoundException, org.gcube.informationsystem.resourceregistry.api.exceptions.ResourceRegistryException String-based counterpart ofResourceRegistryContextClient.changeState(UUID, ContextState).Invocation-specific options and immutable response metadata are available through
RequestInfo.serverResponses().- Specified by:
changeStatein interfaceResourceRegistryContextClient- 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 errors
-