Class TypeManagement
- Author:
- Luca Frosini (ISTI - CNR)
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected StringThe JSON representation of the type.protected booleanFlag forwarded to the innerElementManagementthat persists the type definition vertex, so thatcreate()can preserve themetadataobject already present in the submitted JSON instead of autofilling it.protected booleanFlag to skipdelete()'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 booleanFlag to skipregisterTypeSchema()(the OrientDB class creation/configuration step) duringcreate()— the inverse ofskipTypeDefinitionCreation.protected booleanFlag to skip the superclass-compliance check (getSuperclassesAndCheckCompliancy's "each declared superclass must belong to the same AccessType family" validation) during schema registration.protected booleanFlag to skip database type definition schema creation.protected booleanFlag to skip version check on type updates.protected org.gcube.informationsystem.types.reference.TypeThe Type entity.The set of all registered canonical type names in the registry.protected StringThe name of the type class being managed. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptioncreate()Registers a new type schema and persists its definition.booleandelete()Deletes the specified type schema and its definition from the database.org.gcube.informationsystem.resourceregistry.api.rest.MetadataPolicyReturns the active metadata policy for type serialization.protected com.orientechnologies.orient.core.metadata.schema.OClassReturns the OrientDB OClass schema matching the given typeName.protected com.orientechnologies.orient.core.metadata.schema.OClassgetOClassByUuidOrName(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.TypegetType()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.ElementManagement<?,?> getTypeManagement(com.orientechnologies.orient.core.metadata.schema.OClass oClass) Returns theElementManagementable to read and writeoClass's own type-definition record, resolved from the model familyoClassbelongs to.Returns the name of the type.booleanReturns whether metadata should be obfuscated/masked.booleanReturns whetherdelete()'s referential-integrity guards are skipped.booleanReturns whetherregisterTypeSchema()(OrientDB class creation) is skipped duringcreate().booleanReturns whether the superclass-compliance check is skipped during schema registration.booleanReturns whether database type definition schema creation is skipped.booleanReturns 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 serializedList<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 voidRegisters the database schema (OClass and properties) for the configured Type.voidDeserializes and sets the type definition from its JSON representation.voidsetMaskMetadata(boolean maskMetadata) Configures whether metadata should be obfuscated/masked.voidsetMetadataPolicy(org.gcube.informationsystem.resourceregistry.api.rest.MetadataPolicy metadataPolicy) Configures the metadata policy for type serialization.voidsetPreservePassedMetadata(boolean preservePassedMetadata) Sets whether the inner type definition vertex preserves submittedmetadataas-is on create, instead of autofilling it from the current caller and clock.voidsetSkipReferenceCheck(boolean skipReferenceCheck) Sets whetherdelete()should skip its referential-integrity guards.voidsetSkipSchemaClassCreation(boolean skipSchemaClassCreation) Sets whetherregisterTypeSchema()(OrientDB class creation) should be skipped duringcreate(), e.g. because the type's own class is already known to exist and only its definition row needs (re)creating.voidsetSkipSuperclassComplianceCheck(boolean skipSuperclassComplianceCheck) Sets whether the superclass-compliance check should be skipped during schema registration.voidsetSkipTypeDefinitionCreation(boolean skipTypeDefinitionCreation) Sets whether database type definition schema creation should be skipped.voidsetSkipVersionCheckOnUpdate(boolean skipVersionCheckOnUpdate) Sets whether version checking should be skipped during updates.voidsetTypeAndTypeName(Class<? extends org.gcube.informationsystem.base.reference.Element> clz) Derives the schema, serializes, and sets the type and typeName from the given Java class.voidsetTypeName(String typeName) Sets the name of the type.update()Updates an existing type schema definition in the database.protected voidupdateTypeSchema(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.upsert()Atomically creates the type schema if it does not exist, or updates its definition if it is already present in the database.static StringwithDerivedLockedFlag(String typeJson, String typeName) ReturnstypeJsonwith itslockedflag set to the value derived fortypeName, leaving everything else byte-for-byte untouched.
-
Field Details
-
typeName
The name of the type class being managed. -
json
The JSON representation of the type. -
type
protected org.gcube.informationsystem.types.reference.Type typeThe Type entity. -
skipVersionCheckOnUpdate
protected boolean skipVersionCheckOnUpdateFlag to skip version check on type updates. -
skipTypeDefinitionCreation
protected boolean skipTypeDefinitionCreationFlag to skip database type definition schema creation. -
preservePassedMetadata
protected boolean preservePassedMetadataFlag forwarded to the innerElementManagementthat persists the type definition vertex, so thatcreate()can preserve themetadataobject already present in the submitted JSON instead of autofilling it. Used exclusively by System Restore. -
skipSchemaClassCreation
protected boolean skipSchemaClassCreationFlag to skipregisterTypeSchema()(the OrientDB class creation/configuration step) duringcreate()— the inverse ofskipTypeDefinitionCreation.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 likeGCubePropertythat 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, perDatabaseMigration_5_0_1_to_6_0_0.migrateRenameTypeDefinitionClassesToSchema()). In that case only the definition row needs (re)creating, not the class. -
skipSuperclassComplianceCheck
protected boolean skipSuperclassComplianceCheckFlag 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 ininformation-system-modeland reachable below the externally-exposedEntity/Relation/Propertymodel levels. Some types are internal utility types that were never part of the IS-model at all (e.g.ChildOf, which extendsRelationElementdirectly and has no place in theRelationfamily): for these,information-system-model'sRelationSchemaImpl.getAccessType()has no classification to offer — it cannot even be aware of aresource-registry-internal type without an illegal backwards module dependency — so it falls back toAccessType.RELATION, and the compliance check then wrongly rejects a perfectly legitimateRelationElementsuperclass. 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 skipReferenceCheckFlag to skipdelete()'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
The set of all registered canonical type names in the registry.
-
-
Constructor Details
-
TypeManagement
public TypeManagement()Creates a newTypeManagementinstance 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:
trueif metadata masking is enabled,falseotherwise
-
setMaskMetadata
public void setMaskMetadata(boolean maskMetadata) Configures whether metadata should be obfuscated/masked.- Parameters:
maskMetadata-trueto mask metadata,falseotherwise
-
isSkipVersionCheckOnUpdate
public boolean isSkipVersionCheckOnUpdate()Returns whether version checking is skipped during updates.- Returns:
trueif version checks are skipped,falseotherwise
-
setSkipVersionCheckOnUpdate
public void setSkipVersionCheckOnUpdate(boolean skipVersionCheckOnUpdate) Sets whether version checking should be skipped during updates.- Parameters:
skipVersionCheckOnUpdate-trueto skip,falseto enforce
-
isSkipTypeDefinitionCreation
public boolean isSkipTypeDefinitionCreation()Returns whether database type definition schema creation is skipped.- Returns:
trueif schema creation is skipped,falseotherwise
-
setSkipTypeDefinitionCreation
public void setSkipTypeDefinitionCreation(boolean skipTypeDefinitionCreation) Sets whether database type definition schema creation should be skipped.- Parameters:
skipTypeDefinitionCreation-trueto skip,falseto execute
-
setPreservePassedMetadata
public void setPreservePassedMetadata(boolean preservePassedMetadata) Sets whether the inner type definition vertex preserves submittedmetadataas-is on create, instead of autofilling it from the current caller and clock.- Parameters:
preservePassedMetadata-trueto preserve submitted metadata,falseto autofill
-
isSkipSchemaClassCreation
public boolean isSkipSchemaClassCreation()Returns whetherregisterTypeSchema()(OrientDB class creation) is skipped duringcreate().- Returns:
trueif class creation is skipped,falseotherwise
-
setSkipSchemaClassCreation
public void setSkipSchemaClassCreation(boolean skipSchemaClassCreation) Sets whetherregisterTypeSchema()(OrientDB class creation) should be skipped duringcreate(), e.g. because the type's own class is already known to exist and only its definition row needs (re)creating.- Parameters:
skipSchemaClassCreation-trueto skip,falseto execute
-
isSkipSuperclassComplianceCheck
public boolean isSkipSuperclassComplianceCheck()Returns whether the superclass-compliance check is skipped during schema registration.- Returns:
trueif the check is skipped,falseotherwise
-
setSkipSuperclassComplianceCheck
public void setSkipSuperclassComplianceCheck(boolean skipSuperclassComplianceCheck) Sets whether the superclass-compliance check should be skipped during schema registration.- Parameters:
skipSuperclassComplianceCheck-trueto skip,falseto enforce
-
isSkipReferenceCheck
public boolean isSkipReferenceCheck()Returns whetherdelete()'s referential-integrity guards are skipped.- Returns:
trueif the guards are skipped,falseotherwise
-
setSkipReferenceCheck
public void setSkipReferenceCheck(boolean skipReferenceCheck) Sets whetherdelete()should skip its referential-integrity guards.- Parameters:
skipReferenceCheck-trueto skip,falseto 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 schematypeName- 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
Returns the name of the type.- Returns:
- the name string
-
setTypeName
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
Typeobject
-
getTypeManagement
public ElementManagement<?,?> getTypeManagement(com.orientechnologies.orient.core.metadata.schema.OClass oClass) throws org.gcube.informationsystem.resourceregistry.api.exceptions.types.SchemaNotFoundException Returns theElementManagementable to read and writeoClass's own type-definition record, resolved from the model familyoClassbelongs 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
EntityandRelation, which those four descend from, and finallyPropertyElementas the widest. Matching onPropertyElementrather than onPropertyis what makes every current and futurePropertyElement-category leaf type resolvable without enumerating it by name --MetadataandPropagationConstrainttoday,TemplateVariableonce it exists.- Parameters:
oClass- the OrientDB class to map- Returns:
- the mapped
ElementManagementhelper instance - Throws:
org.gcube.informationsystem.resourceregistry.api.exceptions.types.SchemaNotFoundException- ifoClassbelongs to no family holding type-definition records, and therefore has no definition of its own to read or write (e.g. the purely structuralEntity,Relation,EntityElementandRelationElementclasses)
-
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 connectiontype- the type definition to validatebaseType- the expected base class name- Returns:
- the list of verified
OClasssuperclasses - Throws:
org.gcube.informationsystem.resourceregistry.api.exceptions.types.SchemaException- if compliance checks failorg.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.SchemaExceptionRegisters 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 existsorg.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 ReturnstypeJsonwith itslockedflag set to the value derived fortypeName, 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, andIsModelBootstrap's explicit bootstrap sequence, which persists a handful of definitions through theirElementManagementdirectly and so never passes through this class at all.- Parameters:
typeJson- the serialized type definitiontypeName- the Type's name, used to derive the flag- Returns:
- the same definition with
lockedset - 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 databasenewTypeDefinition- the new type definition to applybaseElementAccessType- the base access type of the element- Throws:
org.gcube.informationsystem.resourceregistry.api.exceptions.types.SchemaNotFoundException- if the type class schema does not existorg.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 readdepth- the depth of subclasses to include (0 = none, N = N levels, -1 = all recursively)- Returns:
- the list of retrieved
Typedefinitions - Throws:
org.gcube.informationsystem.resourceregistry.api.exceptions.ResourceRegistryException- ifbaseOClass'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 connectionoSchema- the OrientDB database schema- Returns:
- the matching
OClass - Throws:
org.gcube.informationsystem.resourceregistry.api.exceptions.NotFoundException- if the UUID or class does not existorg.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
Typedefinitions - Throws:
org.gcube.informationsystem.resourceregistry.api.exceptions.types.SchemaNotFoundException- if the type class schema does not existorg.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.UUIDAlreadyInUseException, org.gcube.informationsystem.resourceregistry.api.exceptions.types.SchemaExceptionRegisters 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 existsorg.gcube.informationsystem.resourceregistry.api.exceptions.UUIDAlreadyInUseException- if the submitted id is occupied by another registry elementorg.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
Typedefinitions - Throws:
org.gcube.informationsystem.resourceregistry.api.exceptions.types.SchemaNotFoundException- if the type schema cannot be foundorg.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 serializedList<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 existorg.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 readdepth- the depth of subclasses to include (0 = none, 1 = direct, -1 = all recursively)- Returns:
- the list of matching
Typedefinitions - Throws:
org.gcube.informationsystem.resourceregistry.api.exceptions.types.SchemaNotFoundException- if the type schema cannot be foundorg.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.SchemaViolationExceptionDeletes the specified type schema and its definition from the database.- Returns:
trueif deletion succeeded- Throws:
org.gcube.informationsystem.resourceregistry.api.exceptions.types.SchemaNotFoundException- if the type schema cannot be foundorg.gcube.informationsystem.resourceregistry.api.exceptions.types.SchemaException- if database deletion failsorg.gcube.informationsystem.resourceregistry.api.exceptions.types.SchemaViolationException- if the type has concrete instances, subtypes, or references from another type definition or from the template of a Query Template
-
update
public String update() throws org.gcube.informationsystem.resourceregistry.api.exceptions.types.SchemaNotFoundException, org.gcube.informationsystem.resourceregistry.api.exceptions.ResourceRegistryExceptionUpdates 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 foundorg.gcube.informationsystem.resourceregistry.api.exceptions.types.SchemaException- if database update failsorg.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.ResourceRegistryExceptionAtomically 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()reportsSchemaAlreadyPresentException) but its definition row does not (soupdate()reportsSchemaNotFoundExceptioninstead of succeeding) — e.g. after a migration dropped and recreated the shared category class the row lived in (seeDatabaseMigration_5_0_1_to_6_0_0.migrateRenameTypeDefinitionClassesToSchema()) while deliberately leaving the type's own class untouched. In that case, retry as a create withsetSkipSchemaClassCreation(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 updateorg.gcube.informationsystem.resourceregistry.api.exceptions.types.SchemaException- if schema compliance or update validations failorg.gcube.informationsystem.resourceregistry.api.exceptions.ResourceRegistryException
-