Class ResourceRegistryContextClientImpl

  • All Implemented Interfaces:
    org.gcube.informationsystem.resourceregistry.api.request.RequestInfo, ResourceRegistryContextClient

    public class ResourceRegistryContextClientImpl
    extends org.gcube.informationsystem.resourceregistry.api.request.BaseRequestInfo
    implements ResourceRegistryContextClient
    Default implementation of 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

      Fields 
      Modifier and Type Field Description
      protected String address
      The base address of the Resource Registry service
      protected org.gcube.informationsystem.resourceregistry.api.contexts.ContextCache contextCache
      Cache for context information to improve performance
      protected org.gcube.informationsystem.resourceregistry.api.contexts.ContextCacheRenewal contextCacheRenewal
      Context cache renewal strategy for refreshing cached context information
      protected Map<String,​String> headers
      HTTP headers to be included in requests
      • Fields inherited from class org.gcube.informationsystem.resourceregistry.api.request.BaseRequestInfo

        allMeta, contextsPolicy, hierarchicalMode, includeMeta, limit, membershipScope, offset
      • Fields inherited from interface org.gcube.informationsystem.resourceregistry.api.request.RequestInfo

        DEFAULT_LIMIT, DEFAULT_OFFSET, UNBOUNDED_LIMIT
    • Constructor Summary

      Constructors 
      Constructor Description
      ResourceRegistryContextClientImpl​(String address)
      This client does not use the shared context cache because it is used by managers to manipulate contexts.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      void addHeader​(String name, boolean value)
      Adds a custom HTTP header to be included in requests.
      void addHeader​(String name, String value)
      Adds 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.
      String changeState​(String context)
      String changeState​(String uuid, String state)
      org.gcube.informationsystem.contexts.reference.entities.Context changeState​(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 affect name or parent.
      org.gcube.informationsystem.contexts.reference.entities.Context changeState​(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.
      String create​(String context)
      Creates a Context from a JSON document supplied through the Java API as a String.
      org.gcube.informationsystem.contexts.reference.entities.Context create​(org.gcube.informationsystem.contexts.reference.entities.Context context)
      Creates a Context through PUT /contexts/{context-uuid}.
      boolean delete​(String uuid)
      Parses uuid and delegates to ResourceRegistryContextClient.delete(UUID) without changing its logical-deletion, authorization, cache, retry, or response-metadata semantics.
      boolean delete​(UUID uuid)
      Logically deletes a live Context, removing it from the active topology while retaining its state and history in the cemetery.
      boolean delete​(org.gcube.informationsystem.contexts.reference.entities.Context context)
      Extracts the Context identifier and delegates to ResourceRegistryContextClient.delete(UUID) without changing its logical-deletion, authorization, cache, or response-metadata semantics.
      boolean exist​(String uuid)
      Checks if a context with the specified UUID (as string) exists in the system.
      boolean exist​(UUID uuid)
      Checks if a context with the specified UUID exists in the system.
      boolean existFromServer​(String uuid)
      Checks if a context with the specified UUID exists on the server, via a direct HEAD /contexts/{uuid} request (the local cache is not consulted).
      List<org.gcube.informationsystem.contexts.reference.entities.Context> getAllContextFromServer()
      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> getAllLiveContextsFromServer()
      Retrieves every live Context from the paginated server endpoint for cache renewal.
      protected Map<String,​String> getAuthorizationHeaders()
      Returns the authentication headers supplied by the active secret provider.
      org.gcube.informationsystem.resourceregistry.api.contexts.ContextCache getContextCache()
      Gets the context cache used for context-related operations.
      protected org.gcube.common.gxhttp.request.GXRequest getGXRequest()
      Creates and configures a GXRequest with authentication headers.
      protected String internalChangeState​(UUID uuid, String context)
      Internal method to change the state of an existing context in the Resource Registry.
      protected String internalCreate​(org.gcube.informationsystem.contexts.reference.entities.Context context)
      Internal method to create a new context in the Resource Registry.
      protected String internalTrackedUpdate​(UUID uuid, String mergePatchJson)
      Sends a Tracked Update merge-patch to the server for the given context, and refreshes the local cache afterwards.
      String 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> query​(String jsonQuery)
      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.
      String read​(String uuid)
      Parses the UUID, delegates to ResourceRegistryContextClient.read(UUID), and serializes the resulting Context hierarchy.
      String read​(String uuid, int depth)
      Parses the UUID, delegates to ResourceRegistryContextClient.read(UUID, int), and serializes the resulting Context hierarchy.
      org.gcube.informationsystem.contexts.reference.entities.Context read​(UUID uuid)
      Retrieves a Context by UUID with root-only depth.
      org.gcube.informationsystem.contexts.reference.entities.Context read​(UUID uuid, int depth)
      Retrieves a Context by UUID and expands descendants to the requested depth.
      org.gcube.informationsystem.contexts.reference.entities.Context read​(org.gcube.informationsystem.contexts.reference.entities.Context context)
      Retrieves a Context by delegating its identifier to ResourceRegistryContextClient.read(UUID).
      org.gcube.informationsystem.contexts.reference.entities.Context read​(org.gcube.informationsystem.contexts.reference.entities.Context context, int depth)
      Retrieves a Context by delegating its identifier and depth to ResourceRegistryContextClient.read(UUID, int).
      org.gcube.informationsystem.contexts.reference.entities.Context readCurrentContext()
      Retrieves the Context associated with the authorization token using root-only depth.
      org.gcube.informationsystem.contexts.reference.entities.Context readCurrentContext​(int depth)
      Retrieves the Context resolved by the server from the authorization token and expands descendants to the requested depth.
      String readFromServer​(String uuid)
      Reads a context from the server by its UUID.
      String 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)
      Parses uuid and delegates to ResourceRegistryContextClient.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 newest Event first.
      String update​(String context)
      Full-Context JSON counterpart of ResourceRegistryContextClient.update(Context).
      String update​(UUID uuid, String mergePatchJson)
      Applies an RFC 7396 merge patch to the Context identified by uuid.
      org.gcube.informationsystem.contexts.reference.entities.Context update​(org.gcube.informationsystem.contexts.reference.entities.Context context)
      Performs a Tracked Update of an existing context: state, name, and parent (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, getContextsPolicy, getLimit, getMembershipScope, getOffset, includeMeta, isHierarchicalMode, setAllMeta, setContextsPolicy, setHierarchicalMode, setIncludeMeta, setLimit, setMembershipScope, setOffset
      • Methods inherited from interface org.gcube.informationsystem.resourceregistry.api.request.RequestInfo

        allMeta, getContextsPolicy, getLimit, getMembershipScope, getOffset, includeMeta, isHierarchicalMode, serverResponses, setAllMeta, setContextsPolicy, setHierarchicalMode, setIncludeMeta, setLimit, setMembershipScope, setOffset
    • Field Detail

      • address

        protected final String address
        The base address of the Resource Registry service
      • headers

        protected Map<String,​String> headers
        HTTP headers to be included in requests
      • contextCache

        protected org.gcube.informationsystem.resourceregistry.api.contexts.ContextCache contextCache
        Cache for context information to improve performance
      • contextCacheRenewal

        protected org.gcube.informationsystem.resourceregistry.api.contexts.ContextCacheRenewal contextCacheRenewal
        Context cache renewal strategy for refreshing cached context information
    • Constructor Detail

      • ResourceRegistryContextClientImpl

        public ResourceRegistryContextClientImpl​(String address)
        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 Detail

      • getAllLiveContextsFromServer

        protected List<org.gcube.informationsystem.contexts.reference.entities.Context> getAllLiveContextsFromServer()
                                                                                                              throws org.gcube.informationsystem.resourceregistry.api.exceptions.ResourceRegistryException
        Retrieves 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

        public void addHeader​(String name,
                              String value)
        Adds a custom HTTP header to be included in requests.

        Invocation-specific options and immutable response metadata are available through RequestInfo.serverResponses().

        Specified by:
        addHeader in interface ResourceRegistryContextClient
        Parameters:
        name - Header name
        value - Header value
      • addHeader

        public void addHeader​(String name,
                              boolean value)
        Adds a custom HTTP header to be included in requests.

        Invocation-specific options and immutable response metadata are available through RequestInfo.serverResponses().

        Specified by:
        addHeader in interface ResourceRegistryContextClient
        Parameters:
        name - Header name
        value - boolean value
      • getGXRequest

        protected org.gcube.common.gxhttp.request.GXRequest getGXRequest()
        Creates and configures a GXRequest with authentication headers.
        Returns:
        A configured GXRequest instance ready for making HTTP requests
      • getAuthorizationHeaders

        protected Map<String,​String> 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.ResourceRegistryException
        It 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 response
        offset - The offset for pagination
        limit - 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 response
        offset - starting position for pagination
        limit - maximum number of Contexts to return
        lifecycle - lifecycle slice to retrieve, or null for 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.ResourceRegistryException
        Retrieves 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:
        all in interface ResourceRegistryContextClient
        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 null lifecycle omits the wire-level lifecycle query parameter and uses the server default (live). Values deleted and all require 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 through RequestInfo.serverResponses() take precedence.

        Specified by:
        all in interface ResourceRegistryContextClient
        Parameters:
        lifecycle - lifecycle slice to retrieve, or null for 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:
        getContextCache in interface ResourceRegistryContextClient
        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 to ResourceRegistryContextClient.query(String, ContextLifecycle) with a null lifecycle (server default: live contexts only).

        Invocation-specific options and immutable response metadata are available through RequestInfo.serverResponses().

        Specified by:
        query in interface ResourceRegistryContextClient
        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 invalid
        org.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/query with the X-HTTP-Method-Override: QUERY header, since the underlying HTTP client does not support issuing a real QUERY request.

        Specified by:
        query in interface ResourceRegistryContextClient
        Parameters:
        jsonQuery - the JSON Query-By-Example payload
        lifecycle - the Context lifecycle slice to search (null for the server default, live); deleted and all are 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 invalid
        org.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 exists
        org.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 through PUT /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 and RequestInfo.serverResponses(). Supplied state and previousPaths values are ignored with a warning; historical paths are administered by ResourceRegistryContextClient.update(UUID, String).

        The token is resolved first: a token of a deleted Context is rejected; a parent that does not exist raises ContextNotFoundException; a parent in the cemetery is a conflict.

        Specified by:
        create in interface ResourceRegistryContextClient
        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 representation
        org.gcube.informationsystem.resourceregistry.api.exceptions.contexts.ContextNotFoundException - if the parent Context does not exist, live or in the cemetery
        org.gcube.informationsystem.resourceregistry.api.exceptions.ResourceRegistryException - if serialization, transport, validation, or authorization fails
        See Also:
        ResourceRegistryContextClient.create(String)
      • 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 a String. The document is decoded locally, assigned a UUID when absent, and sent as an object-valued JSON body through PUT /contexts/{context-uuid}.

        Authorization, idempotency, request-option, and response-metadata behavior is identical to ResourceRegistryContextClient.create(Context).

        Specified by:
        create in interface ResourceRegistryContextClient
        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 representation
        org.gcube.informationsystem.resourceregistry.api.exceptions.contexts.ContextNotFoundException - if the parent Context does not exist, live or in the cemetery
        org.gcube.informationsystem.resourceregistry.api.exceptions.ResourceRegistryException - if decoding, serialization, transport, validation, or authorization fails
        See Also:
        ResourceRegistryContextClient.create(Context)
      • 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 direct HEAD /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 as NotFoundException (its supertype) and translated into a false return value rather than being propagated
        org.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 RequestInfo.serverResponses().

        Implementation Details: UUID Conversion:
        • Converts the string UUID to UUID object using UUID.fromString()
        • Delegates to exist(UUID) for the actual existence check
        Error Handling:
        • Will throw IllegalArgumentException if the string is not a valid UUID format
        • Other exceptions are handled by the delegated exist(UUID) method
        Specified by:
        exist in interface ResourceRegistryContextClient
        Parameters:
        uuid - the UUID of the context (as string) to check for existence
        Returns:
        true if the context exists and is accessible to the current user, false otherwise
        Throws:
        org.gcube.informationsystem.resourceregistry.api.exceptions.ResourceRegistryException - if there are communication errors with the Resource Registry service
      • 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 RequestInfo.serverResponses().

        Implementation Details: Cache-First Strategy:
        • 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()
        Existence Logic:
        • Returns true if read(UUID) succeeds
        • Returns false if read(UUID) throws ContextNotFoundException
        • Propagates other ResourceRegistryException types
        Performance Characteristics:
        • Very Fast: When context is in cache (no server call)
        • Moderate: When cache miss occurs (requires server round-trip via read)
        Authorization Behavior:
        • Returns false for 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:
        exist in interface ResourceRegistryContextClient
        Parameters:
        uuid - the UUID of the context to check for existence
        Returns:
        true if the context exists and is accessible to the current user, false otherwise
        Throws:
        org.gcube.informationsystem.resourceregistry.api.exceptions.ResourceRegistryException - if there are communication errors with the Resource Registry service
      • 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 to ResourceRegistryContextClient.read(UUID).
        Specified by:
        read in interface ResourceRegistryContextClient
        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 found
        org.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 and depth to ResourceRegistryContextClient.read(UUID, int).
        Specified by:
        read in interface ResourceRegistryContextClient
        Parameters:
        context - the context object containing the UUID to retrieve
        depth - ContextPath.DEPTH_ROOT_ONLY for the context alone, a positive integer for that many levels of descendants, or ContextPath.DEPTH_UNLIMITED for the full subtree
        Returns:
        the Context object, with children populated according to depth
        Throws:
        org.gcube.informationsystem.resourceregistry.api.exceptions.contexts.ContextNotFoundException - if the context with the specified UUID is not found
        org.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 to ResourceRegistryContextClient.read(UUID, int) with ContextPath.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:
        read in interface ResourceRegistryContextClient
        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 found
        org.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(). The metadataPolicy and depth request options map to the corresponding query parameters and take precedence for that invocation.

        Depth-expanded reads always bypass the cache (which only holds flat, depth-0 context representations) and go straight to the server.

        Specified by:
        read in interface ResourceRegistryContextClient
        Parameters:
        uuid - the UUID of the context to retrieve
        depth - ContextPath.DEPTH_ROOT_ONLY for the context alone, a positive integer for that many levels of descendants, or ContextPath.DEPTH_UNLIMITED for the full subtree
        Returns:
        the Context object, with children populated according to depth
        Throws:
        org.gcube.informationsystem.resourceregistry.api.exceptions.contexts.ContextNotFoundException - if the context with the specified UUID is not found
        org.gcube.informationsystem.resourceregistry.api.exceptions.ResourceRegistryException - if communication, deserialization, or authorization fails; every role reads every live Context with any token; a Context in the cemetery is readable only by IS-Manager and Infrastructure-Manager
      • 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.ResourceRegistryException
        Retrieves the Context associated with the authorization token using root-only depth. This is equivalent to ResourceRegistryContextClient.readCurrentContext(int) with ContextPath.DEPTH_ROOT_ONLY.
        Specified by:
        readCurrentContext in interface ResourceRegistryContextClient
        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 resolved
        org.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 depth and metadataPolicy request options map to the corresponding query parameters and take precedence for that invocation. Response warnings, links, and canonical content location are available through RequestInfo.serverResponses(). When the token path matches a retained previous path, the response metadata contains X-Result-Scope: previous-path and X-Resolved-Context-Path with the current path.

        Specified by:
        readCurrentContext in interface ResourceRegistryContextClient
        Parameters:
        depth - ContextPath.DEPTH_ROOT_ONLY for the context alone, a positive integer for that many levels of descendants, or ContextPath.DEPTH_UNLIMITED for the full subtree
        Returns:
        the Context object, with children populated according to depth
        Throws:
        org.gcube.informationsystem.resourceregistry.api.exceptions.contexts.ContextNotFoundException - if the token path matches no live Context (current or previous path) and no Context in the cemetery
        org.gcube.informationsystem.resourceregistry.api.exceptions.ResourceRegistryException - if communication, deserialization, or authorization fails; a token whose path matches only a deleted Context is rejected for every role, IS-Manager and Infrastructure-Manager included
      • 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 to ResourceRegistryContextClient.read(UUID), and serializes the resulting Context hierarchy.
        Specified by:
        read in interface ResourceRegistryContextClient
        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 found
        org.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 to ResourceRegistryContextClient.read(UUID, int), and serializes the resulting Context hierarchy.
        Specified by:
        read in interface ResourceRegistryContextClient
        Parameters:
        uuid - the UUID of the context (as string) to retrieve
        depth - ContextPath.DEPTH_ROOT_ONLY for the context alone, a positive integer for that many levels of descendants, or ContextPath.DEPTH_UNLIMITED for the full subtree
        Returns:
        the Context as JSON string, with children populated according to depth
        Throws:
        org.gcube.informationsystem.resourceregistry.api.exceptions.contexts.ContextNotFoundException - if the context with the specified UUID is not found
        org.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 found
        org.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 read
        depth - the hierarchy expansion depth (ContextPath.DEPTH_ROOT_ONLY, a positive integer, or ContextPath.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 found
        org.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.

        Not available on Java 8: the Tracked Update is a PATCH, which HttpURLConnection refuses, so this method throws UnsupportedOperationException before sending anything.

        Parameters:
        uuid - the UUID of the context to update
        mergePatchJson - the application/merge-patch+json body carrying the tracked fields to change
        Returns:
        never returns
        Throws:
        org.gcube.informationsystem.resourceregistry.api.exceptions.contexts.ContextNotFoundException - never thrown
        org.gcube.informationsystem.resourceregistry.api.exceptions.ResourceRegistryException - never thrown
        UnsupportedOperationException - always
      • 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 only state, name, and parent; retained previousPaths are 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 found
        org.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, and parent (as carried by the given object's getters) are sent to the server and applied atomically. The object's previousPaths are deliberately omitted so a stale full representation cannot replace the server's retained set; use ResourceRegistryContextClient.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.

        A reparenting requires a token for the closest common ancestor of the current and the new parent. A Context in the cemetery cannot be updated (409).

        Specified by:
        update in interface ResourceRegistryContextClient
        Parameters:
        context - a Context object (typically obtained via read()) carrying the UUID to update and the desired state/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 found
        org.gcube.informationsystem.resourceregistry.api.exceptions.ResourceRegistryException - if the update is rejected (e.g. rename/reparent while ACTIVE) 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 by uuid. The Java API accepts the object-valued JSON document as a String; it is transmitted unchanged with Content-Type: application/merge-patch+json.

        The patch may contain state, name, parent, and previousPaths. The latter is null or an array of absolute path strings and replaces the complete retained set. metadata, path, effectiveState, and children are dropped without warning; type and id, when present, must identify the addressed Context (400 otherwise); any other field is ignored with a warning. Invocation-specific options and immutable response metadata, including warnings, links, content location, and previous-path resolution headers, are available through RequestInfo.serverResponses().

        Reasserting a previous path already retained by the same Context is a no-op; adding a path owned by another live Context, as its current path or one of its previous paths, is a conflict (409).

        A reparenting requires a token for the closest common ancestor of the current and the new parent. A Context in the cemetery cannot be updated (409).

        Specified by:
        update in interface ResourceRegistryContextClient
        Parameters:
        uuid - the UUID of the Context to update
        mergePatchJson - 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 the requested new parent does not exist, live or in the cemetery
        org.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 of ResourceRegistryContextClient.update(Context). The Java string is decoded as a Context; only state, name, and parent are sent. Use ResourceRegistryContextClient.update(UUID, String) to replace previousPaths or preserve another arbitrary partial merge-patch document unchanged.

        Invocation-specific options and immutable response metadata are available through RequestInfo.serverResponses().

        A reparenting requires a token for the closest common ancestor of the current and the new parent. A Context in the cemetery cannot be updated (409).

        Specified by:
        update in interface ResourceRegistryContextClient
        Parameters:
        context - the JSON string representation of the context carrying the UUID and the desired state/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 found
        org.gcube.informationsystem.resourceregistry.api.exceptions.ResourceRegistryException - if the update is rejected (e.g. rename/reparent while ACTIVE) 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 to ResourceRegistryContextClient.delete(UUID) without changing its logical-deletion, authorization, cache, or response-metadata semantics.
        Specified by:
        delete in interface ResourceRegistryContextClient
        Parameters:
        context - the non-null Context whose non-null identifier selects the deletion target
        Returns:
        true when the server confirms logical deletion
        Throws:
        org.gcube.informationsystem.resourceregistry.api.exceptions.contexts.ContextNotFoundException - if the UUID is unknown, neither live nor in the cemetery
        org.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 returns true; this method never uses false to 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; only IS-Manager and Infrastructure-Manager delete 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 through RequestInfo.serverResponses(); this includes the two previous-path resolution headers when parent scope was established through a retained path.

        Deletion is idempotent: deleting a Context that is already in the cemetery is a successful no-op (204) for IS-Manager and Infrastructure-Manager, and is rejected (403) for other roles.

        Specified by:
        delete in interface ResourceRegistryContextClient
        Parameters:
        uuid - the non-null UUID of the Context to delete
        Returns:
        true when the server confirms logical deletion
        Throws:
        org.gcube.informationsystem.resourceregistry.api.exceptions.contexts.ContextNotFoundException - if the UUID is unknown, neither live nor in the cemetery
        org.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
        Parses uuid and delegates to ResourceRegistryContextClient.delete(UUID) without changing its logical-deletion, authorization, cache, retry, or response-metadata semantics.
        Specified by:
        delete in interface ResourceRegistryContextClient
        Parameters:
        uuid - the non-null textual UUID of the Context to delete
        Returns:
        true when the server confirms logical deletion
        Throws:
        org.gcube.informationsystem.resourceregistry.api.exceptions.contexts.ContextNotFoundException - if the UUID is unknown, neither live nor in the cemetery
        org.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 newest Event first. A Context without recorded events produces an empty list.

        IS-Manager and Infrastructure-Manager read the history of any Context, live or deleted, with any token; IS-Admin reads the history of any live Context with any token; Context-Manager needs a token for the target Context or one of its ancestors. Event.who is returned in full to IS-Manager, Infrastructure-Manager and IS-Admin, and as "[REDACTED]" to Context-Manager. 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 the rel=up link, is available through RequestInfo.serverResponses(). The history includes independent additions, removals, cascades, and path-reuse collision events for previousPaths; previous-path token resolution is exposed through response headers only for Context-Manager calls.

        Specified by:
        readHistory in interface ResourceRegistryContextClient
        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 found
        org.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
        Parses uuid and delegates to ResourceRegistryContextClient.readHistory(UUID) without changing its history, authorization, or response-metadata semantics.
        Specified by:
        readHistory in interface ResourceRegistryContextClient
        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 found
        org.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 to internalTrackedUpdate(UUID, String).
        Parameters:
        uuid - the UUID of the context whose state will be changed
        context - 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 exist
        org.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:
        changeState in interface ResourceRegistryContextClient
        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 found
        org.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 of ResourceRegistryContextClient.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:
        changeState in interface ResourceRegistryContextClient
        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 found
        org.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 affect name or parent.

        Invocation-specific options and immutable response metadata are available through RequestInfo.serverResponses().

        Specified by:
        changeState in interface ResourceRegistryContextClient
        Parameters:
        uuid - the UUID of the context whose state should be changed
        state - 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 found
        org.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 of ResourceRegistryContextClient.changeState(UUID, ContextState).

        Invocation-specific options and immutable response metadata are available through RequestInfo.serverResponses().

        Specified by:
        changeState in interface ResourceRegistryContextClient
        Parameters:
        uuid - the UUID of the context (as string) whose state should be changed
        state - 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 found
        org.gcube.informationsystem.resourceregistry.api.exceptions.ResourceRegistryException - if the state cannot be changed due to authorization issues, invalid state, or other errors