java.lang.Object
org.gcube.informationsystem.resourceregistry.persistence.orientdb.types.TypeManagement

public class TypeManagement extends Object
Management and persistence layer for schemas and types definitions (Resource, Service, Facet, Property, Relation). Handles direct OrientDB schema modifications, type mappings, and Redis caching.
Author:
Luca Frosini (ISTI - CNR)
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    protected String
    The JSON representation of the type.
    protected boolean
    Flag forwarded to the inner ElementManagement that persists the type definition vertex, so that create() can preserve the metadata object already present in the submitted JSON instead of autofilling it.
    protected boolean
    Flag to skip delete()'s referential-integrity guards (still-has-subtypes, still-referenced-as-relation-source-or-target, still-referenced-in-another-Resource's declarations, or still-used as a complex Property type).
    protected boolean
    Flag to skip registerTypeSchema() (the OrientDB class creation/configuration step) during create() — the inverse of skipTypeDefinitionCreation.
    protected boolean
    Flag to skip the superclass-compliance check (getSuperclassesAndCheckCompliancy's "each declared superclass must belong to the same AccessType family" validation) during schema registration.
    protected boolean
    Flag to skip database type definition schema creation.
    protected boolean
    Flag to skip version check on type updates.
    protected org.gcube.informationsystem.types.reference.Type
    The Type entity.
    static Set<String>
    The set of all registered canonical type names in the registry.
    protected String
    The name of the type class being managed.
  • Constructor Summary

    Constructors
    Constructor
    Description
    Creates a new TypeManagement instance with default options.
  • Method Summary

    Modifier and Type
    Method
    Description
    Registers a new type schema and persists its definition.
    boolean
    Deletes the specified type schema and its definition from the database.
    org.gcube.informationsystem.resourceregistry.api.rest.MetadataPolicy
    Returns the active metadata policy for type serialization.
    protected com.orientechnologies.orient.core.metadata.schema.OClass
    getOClass(com.orientechnologies.orient.core.metadata.schema.OSchema oSchema, String typeName)
    Returns the OrientDB OClass schema matching the given typeName.
    protected com.orientechnologies.orient.core.metadata.schema.OClass
    getOClassByUuidOrName(com.orientechnologies.orient.core.db.document.ODatabaseDocument oDatabaseDocument, com.orientechnologies.orient.core.metadata.schema.OSchema oSchema)
    Resolves the OrientDB OClass matching the configured typeName, either by UUID or by direct name.
    List<org.gcube.informationsystem.types.reference.Type>
    getSchema(int depth)
    Returns the schema definitions matching the configured typeName, optionally including subtypes down to a specified depth.
    protected List<com.orientechnologies.orient.core.metadata.schema.OClass>
    getSuperclassesAndCheckCompliancy(com.orientechnologies.orient.core.db.document.ODatabaseDocument oDatabaseDocument, org.gcube.informationsystem.types.reference.Type type, String baseType)
    Resolves superclasses for the type definition and validates schema compliance.
    org.gcube.informationsystem.types.reference.Type
    Returns the Type definition entity.
    protected List<org.gcube.informationsystem.types.reference.Type>
    getTypeDefinitions(com.orientechnologies.orient.core.metadata.schema.OClass baseOClass, int depth)
    Retrieves type definitions for a base class, optionally including subclasses down to a specified depth.
    getTypeManagement(com.orientechnologies.orient.core.metadata.schema.OClass oClass)
    Returns the ElementManagement able to read and write oClass's own type-definition record, resolved from the model family oClass belongs to.
    Returns the name of the type.
    boolean
    Returns whether metadata should be obfuscated/masked.
    boolean
    Returns whether delete()'s referential-integrity guards are skipped.
    boolean
    Returns whether registerTypeSchema() (OrientDB class creation) is skipped during create().
    boolean
    Returns whether the superclass-compliance check is skipped during schema registration.
    boolean
    Returns whether database type definition schema creation is skipped.
    boolean
    Returns whether version checking is skipped during updates.
    List<org.gcube.informationsystem.types.reference.Type>
    read(int depth)
    Reads and returns the list of types matching the requested type name, optionally including all of its subtypes.
    readAsString(int depth)
    Returns the serialized List<Type> JSON array for the given type name/UUID and depth parameter directly from the database, filtering metadata as requested.
    List<org.gcube.informationsystem.types.reference.Type>
    readByUUID(String uuid, int depth)
    Reads and returns the list of types matching the requested type UUID, optionally including its subtypes down to a specified depth.
    protected void
    Registers the database schema (OClass and properties) for the configured Type.
    void
    Deserializes and sets the type definition from its JSON representation.
    void
    setMaskMetadata(boolean maskMetadata)
    Configures whether metadata should be obfuscated/masked.
    void
    setMetadataPolicy(org.gcube.informationsystem.resourceregistry.api.rest.MetadataPolicy metadataPolicy)
    Configures the metadata policy for type serialization.
    void
    setPreservePassedMetadata(boolean preservePassedMetadata)
    Sets whether the inner type definition vertex preserves submitted metadata as-is on create, instead of autofilling it from the current caller and clock.
    void
    setSkipReferenceCheck(boolean skipReferenceCheck)
    Sets whether delete() should skip its referential-integrity guards.
    void
    setSkipSchemaClassCreation(boolean skipSchemaClassCreation)
    Sets whether registerTypeSchema() (OrientDB class creation) should be skipped during create(), e.g. because the type's own class is already known to exist and only its definition row needs (re)creating.
    void
    setSkipSuperclassComplianceCheck(boolean skipSuperclassComplianceCheck)
    Sets whether the superclass-compliance check should be skipped during schema registration.
    void
    setSkipTypeDefinitionCreation(boolean skipTypeDefinitionCreation)
    Sets whether database type definition schema creation should be skipped.
    void
    setSkipVersionCheckOnUpdate(boolean skipVersionCheckOnUpdate)
    Sets whether version checking should be skipped during updates.
    void
    setTypeAndTypeName(Class<? extends org.gcube.informationsystem.base.reference.Element> clz)
    Derives the schema, serializes, and sets the type and typeName from the given Java class.
    void
    setTypeName(String typeName)
    Sets the name of the type.
    Updates an existing type schema definition in the database.
    protected void
    updateTypeSchema(org.gcube.informationsystem.types.reference.Type actualTypeDefinition, org.gcube.informationsystem.types.reference.Type newTypeDefinition, org.gcube.informationsystem.base.reference.AccessType baseElementAccessType)
    Updates the database schema for an existing Type definition.
    Atomically creates the type schema if it does not exist, or updates its definition if it is already present in the database.
    static String
    withDerivedLockedFlag(String typeJson, String typeName)
    Returns typeJson with its locked flag set to the value derived for typeName, leaving everything else byte-for-byte untouched.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

    • typeName

      protected String typeName
      The name of the type class being managed.
    • json

      protected String json
      The JSON representation of the type.
    • type

      protected org.gcube.informationsystem.types.reference.Type type
      The Type entity.
    • skipVersionCheckOnUpdate

      protected boolean skipVersionCheckOnUpdate
      Flag to skip version check on type updates.
    • skipTypeDefinitionCreation

      protected boolean skipTypeDefinitionCreation
      Flag to skip database type definition schema creation.
    • preservePassedMetadata

      protected boolean preservePassedMetadata
      Flag forwarded to the inner ElementManagement that persists the type definition vertex, so that create() can preserve the metadata object already present in the submitted JSON instead of autofilling it. Used exclusively by System Restore.
    • skipSchemaClassCreation

      protected boolean skipSchemaClassCreation
      Flag to skip registerTypeSchema() (the OrientDB class creation/configuration step) during create() — the inverse of skipTypeDefinitionCreation.

      Normal case: the type's own OrientDB class does not exist yet, so create() must create it (registerTypeSchema()) and then persist its definition row. This flag covers the opposite, narrower case: the type's own class already exists (e.g. an instance class like GCubeProperty that was never touched) but its definition *row* — the one living in the shared category class, e.g. PropertySchema — is missing (e.g. because a migration dropped and recreated the category class itself, per DatabaseMigration_5_0_1_to_6_0_0.migrateRenameTypeDefinitionClassesToSchema()). In that case only the definition row needs (re)creating, not the class.

    • skipSuperclassComplianceCheck

      protected boolean skipSuperclassComplianceCheck
      Flag to skip the superclass-compliance check (getSuperclassesAndCheckCompliancy's "each declared superclass must belong to the same AccessType family" validation) during schema registration.

      That validation is driven entirely by Type.getAccessType(), which only classifies types that are actual members of the IS-model — i.e. types registered in information-system-model and reachable below the externally-exposed Entity/Relation/Property model levels. Some types are internal utility types that were never part of the IS-model at all (e.g. ChildOf, which extends RelationElement directly and has no place in the Relation family): for these, information-system-model's RelationSchemaImpl.getAccessType() has no classification to offer — it cannot even be aware of a resource-registry-internal type without an illegal backwards module dependency — so it falls back to AccessType.RELATION, and the compliance check then wrongly rejects a perfectly legitimate RelationElement superclass. This flag is the escape hatch for exactly that situation: a type that simply has no meaningful AccessType to check against. The superclass list itself is still correctly resolved and applied; only the "is-a-subclass-of-baseType" assertion is skipped.

    • skipReferenceCheck

      protected boolean skipReferenceCheck
      Flag to skip delete()'s referential-integrity guards (still-has-subtypes, still-referenced-as-relation-source-or-target, still-referenced-in-another-Resource's declarations, or still-used as a complex Property type). REST deletion must never set this; it exists only for internal migration/test code that needs to remove type definitions in an order the guards would otherwise reject (e.g. dropping a whole family of definitions that reference each other, meant to be recreated together immediately after).
    • typeList

      public static Set<String> typeList
      The set of all registered canonical type names in the registry.
  • Constructor Details

    • TypeManagement

      public TypeManagement()
      Creates a new TypeManagement instance with default options.
  • Method Details

    • getMetadataPolicy

      public org.gcube.informationsystem.resourceregistry.api.rest.MetadataPolicy getMetadataPolicy()
      Returns the active metadata policy for type serialization.
      Returns:
      the metadata policy
    • setMetadataPolicy

      public void setMetadataPolicy(org.gcube.informationsystem.resourceregistry.api.rest.MetadataPolicy metadataPolicy)
      Configures the metadata policy for type serialization.
      Parameters:
      metadataPolicy - the metadata policy to set
    • isMaskMetadata

      public boolean isMaskMetadata()
      Returns whether metadata should be obfuscated/masked.
      Returns:
      true if metadata masking is enabled, false otherwise
    • setMaskMetadata

      public void setMaskMetadata(boolean maskMetadata)
      Configures whether metadata should be obfuscated/masked.
      Parameters:
      maskMetadata - true to mask metadata, false otherwise
    • isSkipVersionCheckOnUpdate

      public boolean isSkipVersionCheckOnUpdate()
      Returns whether version checking is skipped during updates.
      Returns:
      true if version checks are skipped, false otherwise
    • setSkipVersionCheckOnUpdate

      public void setSkipVersionCheckOnUpdate(boolean skipVersionCheckOnUpdate)
      Sets whether version checking should be skipped during updates.
      Parameters:
      skipVersionCheckOnUpdate - true to skip, false to enforce
    • isSkipTypeDefinitionCreation

      public boolean isSkipTypeDefinitionCreation()
      Returns whether database type definition schema creation is skipped.
      Returns:
      true if schema creation is skipped, false otherwise
    • setSkipTypeDefinitionCreation

      public void setSkipTypeDefinitionCreation(boolean skipTypeDefinitionCreation)
      Sets whether database type definition schema creation should be skipped.
      Parameters:
      skipTypeDefinitionCreation - true to skip, false to execute
    • setPreservePassedMetadata

      public void setPreservePassedMetadata(boolean preservePassedMetadata)
      Sets whether the inner type definition vertex preserves submitted metadata as-is on create, instead of autofilling it from the current caller and clock.
      Parameters:
      preservePassedMetadata - true to preserve submitted metadata, false to autofill
    • isSkipSchemaClassCreation

      public boolean isSkipSchemaClassCreation()
      Returns whether registerTypeSchema() (OrientDB class creation) is skipped during create().
      Returns:
      true if class creation is skipped, false otherwise
    • setSkipSchemaClassCreation

      public void setSkipSchemaClassCreation(boolean skipSchemaClassCreation)
      Sets whether registerTypeSchema() (OrientDB class creation) should be skipped during create(), e.g. because the type's own class is already known to exist and only its definition row needs (re)creating.
      Parameters:
      skipSchemaClassCreation - true to skip, false to execute
    • isSkipSuperclassComplianceCheck

      public boolean isSkipSuperclassComplianceCheck()
      Returns whether the superclass-compliance check is skipped during schema registration.
      Returns:
      true if the check is skipped, false otherwise
    • setSkipSuperclassComplianceCheck

      public void setSkipSuperclassComplianceCheck(boolean skipSuperclassComplianceCheck)
      Sets whether the superclass-compliance check should be skipped during schema registration.
      Parameters:
      skipSuperclassComplianceCheck - true to skip, false to enforce
    • isSkipReferenceCheck

      public boolean isSkipReferenceCheck()
      Returns whether delete()'s referential-integrity guards are skipped.
      Returns:
      true if the guards are skipped, false otherwise
    • setSkipReferenceCheck

      public void setSkipReferenceCheck(boolean skipReferenceCheck)
      Sets whether delete() should skip its referential-integrity guards.
      Parameters:
      skipReferenceCheck - true to skip, false to enforce
    • setJson

      public void setJson(String json) throws org.gcube.informationsystem.resourceregistry.api.exceptions.ResourceRegistryException
      Deserializes and sets the type definition from its JSON representation.
      Parameters:
      json - the JSON string representing the type definition
      Throws:
      org.gcube.informationsystem.resourceregistry.api.exceptions.ResourceRegistryException - if the JSON parsing or deserialization fails
    • getOClass

      protected com.orientechnologies.orient.core.metadata.schema.OClass getOClass(com.orientechnologies.orient.core.metadata.schema.OSchema oSchema, String typeName) throws org.gcube.informationsystem.resourceregistry.api.exceptions.types.SchemaException
      Returns the OrientDB OClass schema matching the given typeName.
      Parameters:
      oSchema - the OrientDB database schema
      typeName - the name of the class to get
      Returns:
      the matching OClass
      Throws:
      org.gcube.informationsystem.resourceregistry.api.exceptions.types.SchemaException - if the class does not exist
    • getTypeName

      public String getTypeName()
      Returns the name of the type.
      Returns:
      the name string
    • setTypeName

      public void setTypeName(String typeName)
      Sets the name of the type.
      Parameters:
      typeName - the name to set
    • setTypeAndTypeName

      public void setTypeAndTypeName(Class<? extends org.gcube.informationsystem.base.reference.Element> clz) throws Exception
      Derives the schema, serializes, and sets the type and typeName from the given Java class.
      Parameters:
      clz - the Java Class of the element
      Throws:
      Exception - if mapping or serialization fails
    • getType

      public org.gcube.informationsystem.types.reference.Type getType()
      Returns the Type definition entity.
      Returns:
      the Type object
    • getTypeManagement

      public ElementManagement<?,?> getTypeManagement(com.orientechnologies.orient.core.metadata.schema.OClass oClass) throws org.gcube.informationsystem.resourceregistry.api.exceptions.types.SchemaNotFoundException
      Returns the ElementManagement able to read and write oClass's own type-definition record, resolved from the model family oClass belongs to.

      Each family's definition records live in one shared container class, so the family root -- not the individual type -- is what selects the management. Families are matched from the most specific outwards: the four concrete ER ones first, then Entity and Relation, which those four descend from, and finally PropertyElement as the widest. Matching on PropertyElement rather than on Property is what makes every current and future PropertyElement-category leaf type resolvable without enumerating it by name -- Metadata and PropagationConstraint today, TemplateVariable once it exists.

      Parameters:
      oClass - the OrientDB class to map
      Returns:
      the mapped ElementManagement helper instance
      Throws:
      org.gcube.informationsystem.resourceregistry.api.exceptions.types.SchemaNotFoundException - if oClass belongs to no family holding type-definition records, and therefore has no definition of its own to read or write (e.g. the purely structural Entity, Relation, EntityElement and RelationElement classes)
    • getSuperclassesAndCheckCompliancy

      protected List<com.orientechnologies.orient.core.metadata.schema.OClass> getSuperclassesAndCheckCompliancy(com.orientechnologies.orient.core.db.document.ODatabaseDocument oDatabaseDocument, org.gcube.informationsystem.types.reference.Type type, String baseType) throws org.gcube.informationsystem.resourceregistry.api.exceptions.types.SchemaException, org.gcube.informationsystem.resourceregistry.api.exceptions.types.SchemaNotFoundException
      Resolves superclasses for the type definition and validates schema compliance.
      Parameters:
      oDatabaseDocument - the OrientDB database connection
      type - the type definition to validate
      baseType - the expected base class name
      Returns:
      the list of verified OClass superclasses
      Throws:
      org.gcube.informationsystem.resourceregistry.api.exceptions.types.SchemaException - if compliance checks fail
      org.gcube.informationsystem.resourceregistry.api.exceptions.types.SchemaNotFoundException - if any extended type class does not exist
    • registerTypeSchema

      protected void registerTypeSchema() throws org.gcube.informationsystem.resourceregistry.api.exceptions.types.SchemaAlreadyPresentException, org.gcube.informationsystem.resourceregistry.api.exceptions.types.SchemaException
      Registers the database schema (OClass and properties) for the configured Type.
      Throws:
      org.gcube.informationsystem.resourceregistry.api.exceptions.types.SchemaAlreadyPresentException - if a class with the same name already exists
      org.gcube.informationsystem.resourceregistry.api.exceptions.types.SchemaException - if the schema creation fails
    • withDerivedLockedFlag

      public static String withDerivedLockedFlag(String typeJson, String typeName) throws org.gcube.informationsystem.resourceregistry.api.exceptions.types.SchemaException
      Returns typeJson with its locked flag set to the value derived for typeName, leaving everything else byte-for-byte untouched.

      Exposed as a static helper because the definition record is written from two places: the ordinary create()/update() path, and IsModelBootstrap's explicit bootstrap sequence, which persists a handful of definitions through their ElementManagement directly and so never passes through this class at all.

      Parameters:
      typeJson - the serialized type definition
      typeName - the Type's name, used to derive the flag
      Returns:
      the same definition with locked set
      Throws:
      org.gcube.informationsystem.resourceregistry.api.exceptions.types.SchemaException - if the payload cannot be parsed or rewritten
    • updateTypeSchema

      protected void updateTypeSchema(org.gcube.informationsystem.types.reference.Type actualTypeDefinition, org.gcube.informationsystem.types.reference.Type newTypeDefinition, org.gcube.informationsystem.base.reference.AccessType baseElementAccessType) throws org.gcube.informationsystem.resourceregistry.api.exceptions.types.SchemaNotFoundException, org.gcube.informationsystem.resourceregistry.api.exceptions.types.SchemaException
      Updates the database schema for an existing Type definition.
      Parameters:
      actualTypeDefinition - the current type definition in the database
      newTypeDefinition - the new type definition to apply
      baseElementAccessType - the base access type of the element
      Throws:
      org.gcube.informationsystem.resourceregistry.api.exceptions.types.SchemaNotFoundException - if the type class schema does not exist
      org.gcube.informationsystem.resourceregistry.api.exceptions.types.SchemaException - if update validations (like superclasses match) fail
    • getTypeDefinitions

      protected List<org.gcube.informationsystem.types.reference.Type> getTypeDefinitions(com.orientechnologies.orient.core.metadata.schema.OClass baseOClass, int depth) throws org.gcube.informationsystem.resourceregistry.api.exceptions.ResourceRegistryException
      Retrieves type definitions for a base class, optionally including subclasses down to a specified depth.
      Parameters:
      baseOClass - the base class to read
      depth - the depth of subclasses to include (0 = none, N = N levels, -1 = all recursively)
      Returns:
      the list of retrieved Type definitions
      Throws:
      org.gcube.informationsystem.resourceregistry.api.exceptions.ResourceRegistryException - if baseOClass's own definition record does not exist, or another database error occurs
    • getOClassByUuidOrName

      protected com.orientechnologies.orient.core.metadata.schema.OClass getOClassByUuidOrName(com.orientechnologies.orient.core.db.document.ODatabaseDocument oDatabaseDocument, com.orientechnologies.orient.core.metadata.schema.OSchema oSchema) throws org.gcube.informationsystem.resourceregistry.api.exceptions.NotFoundException, org.gcube.informationsystem.resourceregistry.api.exceptions.ResourceRegistryException
      Resolves the OrientDB OClass matching the configured typeName, either by UUID or by direct name.
      Parameters:
      oDatabaseDocument - the database document connection
      oSchema - the OrientDB database schema
      Returns:
      the matching OClass
      Throws:
      org.gcube.informationsystem.resourceregistry.api.exceptions.NotFoundException - if the UUID or class does not exist
      org.gcube.informationsystem.resourceregistry.api.exceptions.ResourceRegistryException - if the lookup fails
    • getSchema

      public List<org.gcube.informationsystem.types.reference.Type> getSchema(int depth) throws org.gcube.informationsystem.resourceregistry.api.exceptions.types.SchemaNotFoundException, org.gcube.informationsystem.resourceregistry.api.exceptions.ResourceRegistryException
      Returns the schema definitions matching the configured typeName, optionally including subtypes down to a specified depth.
      Parameters:
      depth - the depth of subclasses to include (0 = none, N = N levels, -1 = all recursively)
      Returns:
      the list of matching Type definitions
      Throws:
      org.gcube.informationsystem.resourceregistry.api.exceptions.types.SchemaNotFoundException - if the type class schema does not exist
      org.gcube.informationsystem.resourceregistry.api.exceptions.ResourceRegistryException - if the operation fails
    • create

      public String create() throws org.gcube.informationsystem.resourceregistry.api.exceptions.types.SchemaAlreadyPresentException, org.gcube.informationsystem.resourceregistry.api.exceptions.types.SchemaException
      Registers a new type schema and persists its definition.
      Returns:
      the JSON representation of the created type
      Throws:
      org.gcube.informationsystem.resourceregistry.api.exceptions.types.SchemaAlreadyPresentException - if a schema with the same name already exists
      org.gcube.informationsystem.resourceregistry.api.exceptions.types.SchemaException - if database registration fails
    • read

      public List<org.gcube.informationsystem.types.reference.Type> read(int depth) throws org.gcube.informationsystem.resourceregistry.api.exceptions.types.SchemaNotFoundException, org.gcube.informationsystem.resourceregistry.api.exceptions.ResourceRegistryException
      Reads and returns the list of types matching the requested type name, optionally including all of its subtypes.
      Parameters:
      depth - the depth of subclasses to include (0 = none, 1 = direct, -1 = all recursively)
      Returns:
      the list of matching Type definitions
      Throws:
      org.gcube.informationsystem.resourceregistry.api.exceptions.types.SchemaNotFoundException - if the type schema cannot be found
      org.gcube.informationsystem.resourceregistry.api.exceptions.ResourceRegistryException - if database lookup fails
    • readAsString

      public String readAsString(int depth) throws org.gcube.informationsystem.resourceregistry.api.exceptions.types.SchemaNotFoundException, org.gcube.informationsystem.resourceregistry.api.exceptions.ResourceRegistryException
      Returns the serialized List<Type> JSON array for the given type name/UUID and depth parameter directly from the database, filtering metadata as requested.
      Parameters:
      depth - the depth of subclasses to include (0 = none, 1 = direct, -1 = all recursively)
      Returns:
      serialized JSON array of the type definition(s)
      Throws:
      org.gcube.informationsystem.resourceregistry.api.exceptions.types.SchemaNotFoundException - if the requested type does not exist
      org.gcube.informationsystem.resourceregistry.api.exceptions.ResourceRegistryException - on any other schema-access error
    • readByUUID

      public List<org.gcube.informationsystem.types.reference.Type> readByUUID(String uuid, int depth) throws org.gcube.informationsystem.resourceregistry.api.exceptions.types.SchemaNotFoundException, org.gcube.informationsystem.resourceregistry.api.exceptions.types.SchemaException
      Reads and returns the list of types matching the requested type UUID, optionally including its subtypes down to a specified depth.
      Parameters:
      uuid - the UUID of the type to read
      depth - the depth of subclasses to include (0 = none, 1 = direct, -1 = all recursively)
      Returns:
      the list of matching Type definitions
      Throws:
      org.gcube.informationsystem.resourceregistry.api.exceptions.types.SchemaNotFoundException - if the type schema cannot be found
      org.gcube.informationsystem.resourceregistry.api.exceptions.types.SchemaException - if database lookup fails
    • delete

      public boolean delete() throws org.gcube.informationsystem.resourceregistry.api.exceptions.types.SchemaException, org.gcube.informationsystem.resourceregistry.api.exceptions.types.SchemaNotFoundException, org.gcube.informationsystem.resourceregistry.api.exceptions.types.SchemaViolationException
      Deletes the specified type schema and its definition from the database.
      Returns:
      true if deletion succeeded
      Throws:
      org.gcube.informationsystem.resourceregistry.api.exceptions.types.SchemaNotFoundException - if the type schema cannot be found
      org.gcube.informationsystem.resourceregistry.api.exceptions.types.SchemaException - if database deletion fails
      org.gcube.informationsystem.resourceregistry.api.exceptions.types.SchemaViolationException - if the type has concrete instances, subtypes, or references from another type definition
    • update

      public String update() throws org.gcube.informationsystem.resourceregistry.api.exceptions.types.SchemaNotFoundException, org.gcube.informationsystem.resourceregistry.api.exceptions.ResourceRegistryException
      Updates an existing type schema definition in the database.
      Returns:
      the JSON representation of the updated type
      Throws:
      org.gcube.informationsystem.resourceregistry.api.exceptions.types.SchemaNotFoundException - if the type schema cannot be found
      org.gcube.informationsystem.resourceregistry.api.exceptions.types.SchemaException - if database update fails
      org.gcube.informationsystem.resourceregistry.api.exceptions.ResourceRegistryException
    • upsert

      public String upsert() throws org.gcube.informationsystem.resourceregistry.api.exceptions.types.SchemaNotFoundException, org.gcube.informationsystem.resourceregistry.api.exceptions.ResourceRegistryException
      Atomically creates the type schema if it does not exist, or updates its definition if it is already present in the database.

      Handles one additional, narrower case beyond plain create-vs-update: the type's own OrientDB class already exists (so create() reports SchemaAlreadyPresentException) but its definition row does not (so update() reports SchemaNotFoundException instead of succeeding) — e.g. after a migration dropped and recreated the shared category class the row lived in (see DatabaseMigration_5_0_1_to_6_0_0.migrateRenameTypeDefinitionClassesToSchema()) while deliberately leaving the type's own class untouched. In that case, retry as a create with setSkipSchemaClassCreation(boolean) set, so only the missing definition row is (re)created, not the already-existing class.

      Returns:
      the serialized type definition
      Throws:
      org.gcube.informationsystem.resourceregistry.api.exceptions.types.SchemaNotFoundException - if the type schema is not found during update
      org.gcube.informationsystem.resourceregistry.api.exceptions.types.SchemaException - if schema compliance or update validations fail
      org.gcube.informationsystem.resourceregistry.api.exceptions.ResourceRegistryException