Interface ResourceRegistrySchemaClient
- All Known Implementing Classes:
ResourceRegistrySchemaClientImpl
public interface ResourceRegistrySchemaClient
Client interface for accessing Information System type schemas and model knowledge from the Resource Registry.
Purpose:
This interface provides comprehensive access to the Information System model definitions, type schemas,
hierarchical relationships, and model knowledge within the Resource Registry service. It enables
applications to understand the structure and constraints of available entity and relation types.
Instantiation:
Clients should be created using the factory pattern for proper configuration:
// Recommended way to create a client ResourceRegistrySchemaClient client = ResourceRegistrySchemaClientFactory.create();Supported Operations:
- Schema Access: Retrieve type definitions, properties, and constraints for all Information System types
- Model Knowledge: Access comprehensive model information including type hierarchies and relationships
- Type Discovery: Find available types, their inheritance chains, and compatible subtypes
- Type Validation: Validate type names and class compatibility
- Schema Navigation: Traverse type hierarchies and understand type relationships.
- Type definitions for Resources, Facets, ConsistsOf relations, and IsRelatedTo relations
- Property definitions with types, constraints, and validation rules
- Inheritance hierarchies and polymorphic type relationships
- Schema versioning and evolution information.
- Model knowledge is cached locally to reduce network requests
- Cache can be manually refreshed when schema changes are detected
- Automatic cache invalidation based on schema version changes.
- includeMeta: Include metadata in schema responses.
- Author:
- Luca Frosini (ISTI - CNR)
-
Method Summary
Modifier and TypeMethodDescriptionvoidAdds a custom HTTP header to be included in requests.voidAdds a custom HTTP header to be included in requests.<ME extends org.gcube.informationsystem.model.reference.ModelElement>
org.gcube.informationsystem.types.reference.TypeCreates a new type definition in the Information System using a model element class.Creates a new type definition in the Information System using JSON schema definition.<ME extends org.gcube.informationsystem.model.reference.ModelElement>
booleanChecks if a type definition exists in the Information System using a model element class.booleanChecks if a type definition exists in the Information System using the type name.org.gcube.informationsystem.model.knowledge.ModelKnowledge<org.gcube.informationsystem.types.reference.Type,org.gcube.informationsystem.types.knowledge.TypeInformation> Retrieves the complete model knowledge containing type definitions and their information.<ME extends org.gcube.informationsystem.model.reference.ModelElement>
org.gcube.informationsystem.tree.Node<org.gcube.informationsystem.types.reference.Type>getTypeTreeNode(Class<ME> clz) Retrieves the type tree node for a specific type identified by its model element class.org.gcube.informationsystem.tree.Node<org.gcube.informationsystem.types.reference.Type>getTypeTreeNode(String typeName) Retrieves the type tree node for a specific type identified by its name.booleanReturns whether metadata should be included in schema requests.<ME extends org.gcube.informationsystem.model.reference.ModelElement>
List<org.gcube.informationsystem.types.reference.Type>Reads the type definitions for a specified model element class up to a specific hierarchy level.<ME extends org.gcube.informationsystem.model.reference.ModelElement>
List<org.gcube.informationsystem.types.reference.Type>Reads the type definitions for a specified model element class.Reads the schema definition for a specified type by name up to a specific hierarchy level.Reads the schema definition for a specified type by name.voidForces a renewal of the cached model knowledge by fetching the latest version from the Resource Registry.voidsetIncludeMeta(boolean includeMeta) Sets whether metadata should be included in schema requests.
-
Method Details
-
includeMeta
boolean includeMeta()Returns whether metadata should be included in schema requests.- Returns:
- true if metadata should be included, false otherwise
-
setIncludeMeta
void setIncludeMeta(boolean includeMeta) Sets whether metadata should be included in schema requests.- Parameters:
includeMeta- true to include metadata, false to exclude it
-
getModelKnowledge
org.gcube.informationsystem.model.knowledge.ModelKnowledge<org.gcube.informationsystem.types.reference.Type,org.gcube.informationsystem.types.knowledge.TypeInformation> getModelKnowledge()Retrieves the complete model knowledge containing type definitions and their information. The model knowledge provides access to all registered types and their hierarchical relationships.- Returns:
- the model knowledge containing type definitions and information
-
renewModelKnowledge
void renewModelKnowledge()Forces a renewal of the cached model knowledge by fetching the latest version from the Resource Registry. This method should be called when the schema has been modified and the local cache needs to be updated. -
getTypeTreeNode
org.gcube.informationsystem.tree.Node<org.gcube.informationsystem.types.reference.Type> getTypeTreeNode(String typeName) throws org.gcube.informationsystem.resourceregistry.api.exceptions.types.SchemaNotFoundException, org.gcube.informationsystem.resourceregistry.api.exceptions.ResourceRegistryException Retrieves the type tree node for a specific type identified by its name. The tree node contains the type definition and its hierarchical position within the type system.- Parameters:
typeName- the name of the type to retrieve- Returns:
- the tree node containing the type and its hierarchical information
- Throws:
org.gcube.informationsystem.resourceregistry.api.exceptions.types.SchemaNotFoundException- if the specified type name does not exist in the schemaorg.gcube.informationsystem.resourceregistry.api.exceptions.ResourceRegistryException- if an error occurs during the operation
-
getTypeTreeNode
<ME extends org.gcube.informationsystem.model.reference.ModelElement> org.gcube.informationsystem.tree.Node<org.gcube.informationsystem.types.reference.Type> getTypeTreeNode(Class<ME> clz) throws org.gcube.informationsystem.resourceregistry.api.exceptions.types.SchemaNotFoundException, org.gcube.informationsystem.resourceregistry.api.exceptions.ResourceRegistryException Retrieves the type tree node for a specific type identified by its model element class. The tree node contains the type definition and its hierarchical position within the type system.- Type Parameters:
ME- the model element type parameter- Parameters:
clz- the class of the model element type to retrieve- Returns:
- the tree node containing the type and its hierarchical information
- Throws:
org.gcube.informationsystem.resourceregistry.api.exceptions.types.SchemaNotFoundException- if the specified type does not exist in the schemaorg.gcube.informationsystem.resourceregistry.api.exceptions.ResourceRegistryException- if an error occurs during the operation
-
addHeader
Adds a custom HTTP header to be included in requests.- Parameters:
name- Header namevalue- Header value
-
addHeader
Adds a custom HTTP header to be included in requests.- Parameters:
name- Header namevalue- boolean value
-
create
String create(String typeDefinitition) throws org.gcube.informationsystem.resourceregistry.api.exceptions.types.SchemaException, org.gcube.informationsystem.resourceregistry.api.exceptions.ResourceRegistryException Creates a new type definition in the Information System using JSON schema definition. Corresponding REST API:PUT /types/{type-name}Operation Behavior:- Creates a new type definition from JSON schema representation
- Type name is extracted from the JSON schema definition
- Validates the JSON schema against Information System type schema requirements
- Type definitions become available system-wide for instance creation
- Returns the complete type definition including metadata and schema information.
- 201 Created: Type successfully created
- 409 Conflict: Type already exists with the given name
- 400 Bad Request: Invalid JSON schema or malformed request
- 403 Forbidden: User lacks authorization to create types.
- JSON schema must conform to Information System type schema format
- Type name must be unique in the system
- Schema must define valid properties, relationships, and constraints.
- All type properties and relationships are validated against the Information System model
- Type hierarchy and inheritance rules are enforced
- Property types and constraints are validated
- Relationship definitions must reference valid types.
- IS-Manager: Can create any type definition without restrictions
- Infrastructure-Manager: Can create any type definition without restrictions
- All Other Users: Cannot create type definitions (will receive authorization errors)
- Type creation is restricted to prevent system-wide compatibility issues.
ResourceRegistrySchemaClient client = ResourceRegistrySchemaClientFactory.create(); // Create a new type from JSON schema String jsonSchema = "{ \"@class\": \"ContactFacet\", ... }"; String createdType = client.create(jsonSchema);Context Access:- Type definitions are global and not bound to a specific context.
- Parameters:
typeDefinitition- the JSON schema definition of the type to create- Returns:
- the JSON representation of the created type definition
- Throws:
org.gcube.informationsystem.resourceregistry.api.exceptions.types.SchemaException- if the provided schema is invalid or malformedorg.gcube.informationsystem.resourceregistry.api.exceptions.ResourceRegistryException- for creation errors or authorization failures
-
create
<ME extends org.gcube.informationsystem.model.reference.ModelElement> org.gcube.informationsystem.types.reference.Type create(Class<ME> clz) throws org.gcube.informationsystem.resourceregistry.api.exceptions.types.SchemaException, org.gcube.informationsystem.resourceregistry.api.exceptions.ResourceRegistryException Creates a new type definition in the Information System using a model element class. Corresponding REST API:PUT /types/{type-name}Operation Behavior:- Creates a new type definition derived from the provided model element class
- Type name is automatically derived from the class using reflection
- Analyzes class annotations and structure to generate the type schema
- Type definitions become available system-wide for instance creation
- Returns the complete Type object with metadata and schema information.
- 201 Created: Type successfully created
- 409 Conflict: Type already exists with the given name
- 400 Bad Request: Invalid class definition or schema generation failure
- 403 Forbidden: User lacks authorization to create types.
- Type name is automatically derived from the provided class using
TypeUtility.getTypeName(Class) - Class must extend ModelElement or its subtypes
- Annotations are processed to generate schema constraints
- Property definitions are extracted from class fields and methods.
- All class properties and relationships are validated against the Information System model
- Type hierarchy and inheritance rules are enforced
- Property types and constraints are validated from class annotations
- Relationship definitions must reference valid types.
- IS-Manager: Can create any type definition without restrictions
- Infrastructure-Manager: Can create any type definition without restrictions
- All Other Users: Cannot create type definitions (will receive authorization errors)
- Type creation is restricted to prevent system-wide compatibility issues.
ResourceRegistrySchemaClient client = ResourceRegistrySchemaClientFactory.create(); // Create a new type from model element class Type createdType = client.create(ContactFacet.class);
- Type Parameters:
ME- the model element type parameter- Parameters:
clz- the class of the model element type to create- Returns:
- the Type object representing the created type definition
- Throws:
org.gcube.informationsystem.resourceregistry.api.exceptions.types.SchemaException- if the class definition is invalid or schema generation failsorg.gcube.informationsystem.resourceregistry.api.exceptions.ResourceRegistryException- for creation errors or authorization failures Context Access:- Type definitions are global and not bound to a specific context.
-
exist
boolean exist(String typeName) throws org.gcube.informationsystem.resourceregistry.api.exceptions.ResourceRegistryException Checks if a type definition exists in the Information System using the type name. Corresponding REST API:HEAD /types/{type-name}[?polymorphic={true|false}&includeMeta={true|false}]Operation Behavior:- Verifies the existence of the specified type definition using its name
- Does not return the type data, only confirms existence
- Checks accessibility within the current user authorization level
- Most direct method when type name is already known.
- 200 OK: Type exists and is accessible
- 404 Not Found: Type does not exist in the system
- 403 Forbidden: User lacks authorization to access type information
- 401 Unauthorized: Invalid or missing authentication credentials.
- Type name must be a valid Information System model type
- Supports all Information System model types and their subtypes: Entities (Resources and all Resource subtypes, Facets and all Facet subtypes) and Relations (ConsistsOf and all ConsistsOf subtypes, IsRelatedTo and all IsRelatedTo subtypes)
- Type name is case-sensitive and must match exactly.
- IS-Manager: Can check existence of any type definition
- Infrastructure-Manager: Can check existence of any type definition
- All Other Users: Can check existence of any type definition with filtered access to sensitive metadata.
ResourceRegistrySchemaClient client = ResourceRegistrySchemaClientFactory.create(); // Check if ContactFacet type exists boolean contactFacetExists = client.exist("ContactFacet"); // Check if a custom resource type exists boolean customResourceExists = client.exist("MyCustomResource");- Parameters:
typeName- the name of the type to check for existence (case-sensitive)- Returns:
- true if the type exists in the system, false if not found
- Throws:
org.gcube.informationsystem.resourceregistry.api.exceptions.ResourceRegistryException- if an error occurs during the existence check
-
exist
<ME extends org.gcube.informationsystem.model.reference.ModelElement> boolean exist(Class<ME> clz) throws org.gcube.informationsystem.resourceregistry.api.exceptions.ResourceRegistryException Checks if a type definition exists in the Information System using a model element class. Corresponding REST API:HEAD /types/{type-name}[?polymorphic={true|false}&includeMeta={true|false}]Operation Behavior:- Verifies the existence of the specified type definition using its model element class
- Type name is automatically derived from the class using reflection
- Does not return the type data, only confirms existence
- Checks accessibility within the current user authorization level
- Convenient method when working with strongly-typed classes.
- 200 OK: Type exists and is accessible
- 404 Not Found: Type corresponding to the class does not exist in the system
- 403 Forbidden: User lacks authorization to access type information
- 401 Unauthorized: Invalid or missing authentication credentials.
- The type name is automatically derived from the provided class using
TypeUtility.getTypeName(Class) - Class must extend ModelElement or its subtypes
- Supports all Information System model types and their subtypes: Entities (Resources and all Resource subtypes, Facets and all Facet subtypes) and Relations (ConsistsOf and all ConsistsOf subtypes, IsRelatedTo and all IsRelatedTo subtypes).
- IS-Manager: Can check existence of any type definition
- Infrastructure-Manager: Can check existence of any type definition
- All Other Users: Can check existence of any type definition with filtered access to sensitive metadata.
ResourceRegistrySchemaClient client = ResourceRegistrySchemaClientFactory.create(); // Check if ContactFacet type exists boolean contactFacetExists = client.exist(ContactFacet.class); // Check if EService type exists boolean eServiceExists = client.exist(EService.class);
- Type Parameters:
ME- the model element type parameter- Parameters:
clz- the class of the model element type to check for existence- Returns:
- true if the type corresponding to the class exists in the system, false if not found
- Throws:
org.gcube.informationsystem.resourceregistry.api.exceptions.ResourceRegistryException- if an error occurs during the existence check
-
read
String read(String typeName, Boolean polymorphic) throws org.gcube.informationsystem.resourceregistry.api.exceptions.types.SchemaNotFoundException, org.gcube.informationsystem.resourceregistry.api.exceptions.ResourceRegistryException Reads the schema definition for a specified type by name. Corresponding REST API:GET /types/{type-name}[?polymorphic={true|false}&includeMeta={true|false}]Operation Behavior:- Retrieves type schema definition(s) for the specified type name
- When polymorphic=false: returns only the specified type definition
- When polymorphic=true: returns the specified type AND all its existing subtypes
- Metadata inclusion is controlled by client configuration and user authorization
- Response detail level varies based on user authorization (IS/Infrastructure managers get full metadata).
- 200 OK: Type successfully retrieved
- 404 Not Found: Type with the specified name does not exist
- 403 Forbidden: User lacks authorization to access type information.
- Whether to include subtypes in the response
- Default value: false (returns only the specified type)
- Values: true (includes all subtypes) | false (specified type only)
- When true: returns the specified type AND all its existing subtypes
- When false: returns only the specified type definition
- Note: No pagination is applied - ALL subtypes are returned when polymorphic=true.
- Whether to include metadata in the response type definition
- Default value: false (basic type information only)
- Usage:
client.setIncludeMeta(true) - Values: true (includes metadata with role-based filtering) | false (basic information only)
- Query parameter:
TypePath.INCLUDE_META_QUERY_PARAMETER - Restriction: IS-Manager and Infrastructure-Manager see complete metadata including sensitive information (createdBy, lastUpdatedBy); other users see filtered metadata with sensitive fields obfuscated.
- IS-Manager: Receive complete type definitions with full metadata when requested
- Infrastructure-Manager: Receive complete type definitions with full metadata when requested
- All Other Users: Receive basic type information with filtered metadata (sensitive information obfuscated).
ResourceRegistrySchemaClient client = ResourceRegistrySchemaClientFactory.create(); // Read a ContactFacet type definition only String contactFacetSchema = client.read("ContactFacet", false); // Read ContactFacet and all its subtypes String contactFacetAndSubtypes = client.read("ContactFacet", true);- Parameters:
typeName- the name of the type to retrieve (case-sensitive)polymorphic- whether to include subtypes in the response (when true, includes all subtypes)- Returns:
- JSON string containing type schema definition(s) with authorization-appropriate detail level
- Throws:
org.gcube.informationsystem.resourceregistry.api.exceptions.types.SchemaNotFoundException- if the specified type is not found in the systemorg.gcube.informationsystem.resourceregistry.api.exceptions.ResourceRegistryException- for retrieval errors or other system failures
-
read
<ME extends org.gcube.informationsystem.model.reference.ModelElement> List<org.gcube.informationsystem.types.reference.Type> read(Class<ME> clz, Boolean polymorphic) throws org.gcube.informationsystem.resourceregistry.api.exceptions.types.SchemaNotFoundException, org.gcube.informationsystem.resourceregistry.api.exceptions.ResourceRegistryException Reads the type definitions for a specified model element class. Corresponding REST API:GET /types/{type-name}[?polymorphic={true|false}&includeMeta={true|false}]Operation Behavior:- Retrieves type definitions for the specified model element class
- Type name is automatically derived from the class using reflection
- When polymorphic=false: returns only the specified type definition
- When polymorphic=true: returns the specified type AND all its existing subtypes
- Returns strongly-typed Type objects instead of JSON strings
- Response detail level varies based on user authorization.
- 200 OK: Type successfully retrieved
- 404 Not Found: Type corresponding to the specified class does not exist
- 403 Forbidden: User lacks authorization to access type information.
- Whether to include subtypes in the response
- Default value: false (returns only the specified type)
- Values: true (includes all subtypes) | false (specified type only)
- When true: returns the specified type AND all its existing subtypes
- When false: returns only the specified type definition
- Note: No pagination is applied - ALL subtypes are returned when polymorphic=true.
- Whether to include metadata in the response type definition
- Default value: false (basic type information only)
- Usage:
client.setIncludeMeta(true) - Values: true (includes metadata with role-based filtering) | false (basic information only)
- Query parameter:
TypePath.INCLUDE_META_QUERY_PARAMETER - Restriction: IS-Manager and Infrastructure-Manager see complete metadata including sensitive information (createdBy, lastUpdatedBy); other users see filtered metadata with sensitive fields obfuscated.
- The type name is automatically derived from the provided class using
TypeUtility.getTypeName(Class).
- IS-Manager: Receive complete type definitions with full metadata when requested
- Infrastructure-Manager: Receive complete type definitions with full metadata when requested
- All Other Users: Receive basic type information with filtered metadata (sensitive information obfuscated).
ResourceRegistrySchemaClient client = ResourceRegistrySchemaClientFactory.create(); // Read ContactFacet type definition only List<Type> contactFacetType = client.read(ContactFacet.class, false); // Read ContactFacet and all its subtypes List<Type> contactFacetAndSubtypes = client.read(ContactFacet.class, true);
- Type Parameters:
ME- the model element type parameter- Parameters:
clz- the class of the model element type to retrievepolymorphic- whether to include subtypes in the response (when true, includes all subtypes)- Returns:
- list of Type objects representing the type definition(s) with authorization-appropriate detail level
- Throws:
org.gcube.informationsystem.resourceregistry.api.exceptions.types.SchemaNotFoundException- if the type corresponding to the specified class is not foundorg.gcube.informationsystem.resourceregistry.api.exceptions.ResourceRegistryException- for retrieval errors or other system failures
-
read
String read(String typeName, int level) throws org.gcube.informationsystem.resourceregistry.api.exceptions.types.SchemaNotFoundException, org.gcube.informationsystem.resourceregistry.api.exceptions.ResourceRegistryException Reads the schema definition for a specified type by name up to a specific hierarchy level. Corresponding REST API:GET /types/{type-name}[?polymorphic={true|false}&includeMeta={true|false}]Operation Behavior:- Retrieves type schema definition for the specified type name
- Limits the depth of hierarchical relationships to the specified level
- Level parameter controls how deep into related types the response includes
- Useful for preventing overly complex responses in deeply nested type hierarchies
- Response detail level varies based on user authorization.
- 200 OK: Type successfully retrieved
- 404 Not Found: Type with the specified name does not exist
- 403 Forbidden: User lacks authorization to access type information.
- Controls the depth of hierarchical relationships included in the response
- Higher values include more detailed relationship information
- Lower values provide more concise responses with limited relationship depth
- Useful for controlling response size and complexity.
- Whether to include metadata in the response type definition
- Default value: false (basic type information only)
- Usage:
client.setIncludeMeta(true) - Values: true (includes metadata with role-based filtering) | false (basic information only)
- Query parameter:
TypePath.INCLUDE_META_QUERY_PARAMETER - Restriction: IS-Manager and Infrastructure-Manager see complete metadata including sensitive information (createdBy, lastUpdatedBy); other users see filtered metadata with sensitive fields obfuscated.
- IS-Manager: Receive complete type definitions with full metadata when requested
- Infrastructure-Manager: Receive complete type definitions with full metadata when requested
- All Other Users: Receive basic type information with filtered metadata (sensitive information obfuscated).
ResourceRegistrySchemaClient client = ResourceRegistrySchemaClientFactory.create(); // Read ContactFacet type definition with hierarchy level 1 String contactFacetSchema = client.read("ContactFacet", 1); // Read ContactFacet type definition with deeper hierarchy level String contactFacetDeepSchema = client.read("ContactFacet", 3);- Parameters:
typeName- the name of the type to retrieve (case-sensitive)level- the maximum hierarchy level to include in the response- Returns:
- JSON string containing type schema definition with hierarchy limited to the specified level
- Throws:
org.gcube.informationsystem.resourceregistry.api.exceptions.types.SchemaNotFoundException- if the specified type is not found in the systemorg.gcube.informationsystem.resourceregistry.api.exceptions.ResourceRegistryException- for retrieval errors or other system failures
-
read
<ME extends org.gcube.informationsystem.model.reference.ModelElement> List<org.gcube.informationsystem.types.reference.Type> read(Class<ME> clz, int level) throws org.gcube.informationsystem.resourceregistry.api.exceptions.types.SchemaNotFoundException, org.gcube.informationsystem.resourceregistry.api.exceptions.ResourceRegistryException Reads the type definitions for a specified model element class up to a specific hierarchy level. Corresponding REST API:GET /types/{type-name}[?polymorphic={true|false}&includeMeta={true|false}]Operation Behavior:- Retrieves type definitions for the specified model element class
- Type name is automatically derived from the class using reflection
- Limits the depth of hierarchical relationships to the specified level
- Level parameter controls how deep into related types the response includes
- Returns strongly-typed Type objects instead of JSON strings
- Response detail level varies based on user authorization.
- 200 OK: Type successfully retrieved
- 404 Not Found: Type corresponding to the specified class does not exist
- 403 Forbidden: User lacks authorization to access type information.
- Controls the depth of hierarchical relationships included in the response
- Higher values include more detailed relationship information
- Lower values provide more concise responses with limited relationship depth
- Useful for controlling response size and complexity.
- Whether to include metadata in the response type definition
- Default value: false (basic type information only)
- Usage:
client.setIncludeMeta(true) - Values: true (includes metadata with role-based filtering) | false (basic information only)
- Query parameter:
TypePath.INCLUDE_META_QUERY_PARAMETER - Restriction: IS-Manager and Infrastructure-Manager see complete metadata including sensitive information (createdBy, lastUpdatedBy); other users see filtered metadata with sensitive fields obfuscated.
- The type name is automatically derived from the provided class using
TypeUtility.getTypeName(Class).
- IS-Manager: Receive complete type definitions with full metadata when requested
- Infrastructure-Manager: Receive complete type definitions with full metadata when requested
- All Other Users: Receive basic type information with filtered metadata (sensitive information obfuscated).
ResourceRegistrySchemaClient client = ResourceRegistrySchemaClientFactory.create(); // Read ContactFacet type definition with hierarchy level 1 List<Type> contactFacetType = client.read(ContactFacet.class, 1); // Read ContactFacet type definition with deeper hierarchy level List<Type> contactFacetDeepType = client.read(ContactFacet.class, 3);
- Type Parameters:
ME- the model element type parameter- Parameters:
clz- the class of the model element type to retrievelevel- the maximum hierarchy level to include in the response- Returns:
- list of Type objects representing the type definition(s) with hierarchy limited to the specified level
- Throws:
org.gcube.informationsystem.resourceregistry.api.exceptions.types.SchemaNotFoundException- if the type corresponding to the specified class is not foundorg.gcube.informationsystem.resourceregistry.api.exceptions.ResourceRegistryException- for retrieval errors or other system failures
-