Class ElementManagement<El extends com.orientechnologies.orient.core.record.OElement,T extends org.gcube.informationsystem.types.reference.Type>
- Type Parameters:
El- the specific OrientDBOElementsubtype (vertex or edge) this class managesT- the corresponding schemaTypedefinition interface
- Direct Known Subclasses:
EntityElementManagement,PropertySchemaManagement,RelationElementManagement
preservePassedMetadata,
privacy masking).
This class carries no security-role, token, or permission logic of its own: every
behavioral choice it makes is driven exclusively by the explicit flags/values a caller sets
on it before invoking an operation (e.g. metadataPolicy, maskMetadata,
updateMode, dryRun) — authorization is the exclusive responsibility of the
Policy Enforcement Point layer, which configures an instance of this class and never the
other way around.
- Author:
- Luca Frosini (ISTI - CNR)
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected final org.gcube.informationsystem.base.reference.AccessTypeThe access type category.Accumulates the UUID -> JSON representation of every instance actually affected by a Delete, addToContext, or removeFromContext cascade, so the caller can be told what changed (e.g. an Operation Envelope).static final StringSymbol constant for at.protected CachedType<T>The cached schema type definition.protected org.gcube.com.fasterxml.jackson.databind.JsonNodeThe complete serialized JSON node representing the element and its relationships.static final StringString constant representing deleted state.static final StringSymbol constant for dollar.protected booleanFlag indicating whether this operation is a simulation (dry run) which should end with a transaction rollback instead of a commit.protected ElThe loaded OrientDB record element instance.The specific class of the OrientDB element.protected booleanWhether this management instance is the entry point of the current operation, as opposed to a subordinated one triggered on a related instance during cascading.protected List<IgnoredFields>Collects the fields each written instance dropped because its category does not accept them.Keys to ignore during property mapping.Key prefixes to ignore during property mapping.protected org.gcube.com.fasterxml.jackson.databind.JsonNodeThe input JSON payload node representing the element.protected IntegerPagination limit for list operations.protected org.slf4j.LoggerThe logger instance for auditing and diagnostics.protected booleanWhentrue,metadata'screatedBy/lastUpdateByfields are privacy-masked (seeapplyPrivacyMask(ObjectNode)) while serializing this element.protected org.gcube.informationsystem.resourceregistry.api.rest.MetadataPolicyMetadata projection policy for this management operation, set explicitly by the caller (typically the PEP layer).protected com.orientechnologies.orient.core.metadata.schema.OClassThe OrientDB schema class.protected com.orientechnologies.orient.core.db.document.ODatabaseDocumentThe active database document session.protected IntegerPagination offset for list operations.protected OperationIt is assigned only in the entry pointprotected booleanWhether the queries should include subclasses polymorphic results.protected booleanWhentrue,internalCreate()preserves themetadataobject already present in the submitted JSON (creator, creation/last-update timestamps) instead of autofilling it from the current caller and clock.protected booleanWhether to force a reload from the database.protected booleanDefers sanity checks for atomic orchestration flows that validate the final graph state explicitly before committing.protected org.gcube.com.fasterxml.jackson.databind.JsonNodeThe serialized JSON node representing only the element's direct properties.protected StringThe name of the schema type.static final StringSymbol constant for underscore.protected UpdateModeDefines whether an update should merge into or replace the existing state.protected UUIDThe UUID identifier of the element.protected EnvironmentThe active database working environment. -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedElementManagement(org.gcube.informationsystem.base.reference.AccessType accessType) Creates a newElementManagementinstance for the specified access type.protectedElementManagement(org.gcube.informationsystem.base.reference.AccessType accessType, String typeName) Creates a newElementManagementinstance for the specified access type and type name. -
Method Summary
Modifier and TypeMethodDescriptionprotected voidaddIgnoredFields(Set<String> fields) Records the fields this instance dropped, if any.protected voidCalled every time a write records on the element the caller and the time of its latest modification: the point where the modification is recorded on whatever else it modifies.all()Retrieves and returns all elements of this type from the database as a JSON array string.static org.gcube.com.fasterxml.jackson.databind.node.ObjectNodeapplyPrivacyMask(org.gcube.com.fasterxml.jackson.databind.node.ObjectNode metadataJson) Masks privacy-sensitive fields in the given metadata JSON node by replacingMetadata.CREATED_BY_PROPERTYandMetadata.LAST_UPDATE_BY_PROPERTYwith theElement.REDACTEDplaceholder.static org.gcube.com.fasterxml.jackson.databind.node.ObjectNodeapplyPrivacyMask(org.gcube.com.fasterxml.jackson.databind.node.ObjectNode metadataJson, boolean keepUserMeta) Masks privacy-sensitive fields in the given metadata JSON node, with optional identity-aware behaviour controlled bykeepUserMeta.protected voidValidates that the schema type of the JSON node matches the configured type name.protected voidValidates the input JSON node and extracts the UUID and schema type.protected voidValidates that the UUID inside the JSON node matches the configured element UUID.protected voidRejects UUID reuse before creating a brand-new element: a UUID is occupied by any element of any type in any Context, and a creation with an occupied UUID is a conflict.protected voidInvalidates the cached direct and complete JSON representations.protected voidconcludeTransaction(String successMessage) Concludes the active database transaction.create()Creates a new element in the database.protected abstract org.gcube.com.fasterxml.jackson.databind.JsonNodeAbstract method to create the complete JSON node representation of the element.Atomically creates or updates the element in the database (idempotent upsert).Atomically creates or updates the element and preserves the resulting operation kind.voiddelete()Deletes this element from the database.booleanexists()Returns whether the element with the configured UUID exists in the database.org.gcube.informationsystem.base.reference.AccessTypeReturns the access type category of this element.Returns the map of instances affected by operations on this element.protected Set<org.gcube.informationsystem.types.reference.properties.PropertyDefinition>Retrieves and returns all property definitions for this schema type, including those inherited from all of its supertypes.protected CachedType<T>Returns the cached schema type definition, initializing it if not present.static com.orientechnologies.orient.core.db.document.ODatabaseDocumentReturns theODatabaseDocumentcurrently bound to this thread by OrientDB's thread-local stack, ornullif no database is active on this thread.Returns the OrientDB element instance, retrieving and caching it if not already present.Returns the fields dropped by the instances written by this operation.getLimit()Gets the pagination limit.protected StringgetMandatoryErrorMessage(String fieldName) Formats and returns the error message for a missing mandatory field schema violation.static StringgetMandatoryErrorMessage(String typeName, String fieldName) Formats and returns the error message for a missing mandatory field of the given type.org.gcube.informationsystem.resourceregistry.api.rest.MetadataPolicyReturns the metadata projection policy.protected com.orientechnologies.orient.core.metadata.schema.OClassReturns the schema class (OClass) associated with this element.Gets the pagination offset.protected org.gcube.com.fasterxml.jackson.databind.JsonNodegetPropertyForJson(String key, Object object) Converts an OrientDB property value object into a JacksonJsonNodefor JSON serialization.getPropertyMap(org.gcube.com.fasterxml.jackson.databind.JsonNode jsonNode, Set<String> ignoreKeys, Set<String> ignoreStartWith) Extracts and returns a flat key-value map of properties from a JSON representation node, skipping any ignored keys and prefixes.protected abstract org.gcube.informationsystem.resourceregistry.api.exceptions.AlreadyPresentExceptiongetSpecificAlreadyPresentException(String message) Converts a generic AlreadyPresentException into a subclass-specific AlreadyPresentException.protected abstract org.gcube.informationsystem.resourceregistry.api.exceptions.NotFoundExceptiongetSpecificNotFoundException(org.gcube.informationsystem.resourceregistry.api.exceptions.NotFoundException e) Converts a generic NotFoundException into a subclass-specific NotFoundException.Returns the canonical type name of the element.Returns the update mode used by update operations.getUUID()Returns the UUID identifier of this element.protected abstract EnvironmentReturns the active database working environment.Performs the internal database creation and registration of the element.Performs an internal idempotent database upsert (update if exists, otherwise create).voidDeletes an existing element from the database.Performs the internal database update and metadata refresh of the element.static booleanisBackendLinkFieldName(String name) Returns whether a name is reserved to the backend fields linking Entities and Relations:in,outand every name starting within_orout_, in lower or upper case.booleanisDryRun()Returns whether this operation is running as a dry run simulation.booleanReturns whether privacy masking is enabled for metadata fields.booleanGets whether polymorphic queries are enabled.booleanReturns whether a submittedmetadataobject is preserved as-is on create, instead of being autofilled from the current caller and clock.booleanisReload()Returns whether to force a reload from the database.booleanReturns whether sanity checks are deferred to the caller.read()Reads and returns the complete serialized JSON string of the element.protected abstract ElPersists a new element in the database (subclass hook).protected abstract voidDeletes an existing element from the database (subclass hook).abstract StringRetrieves all elements from the database and returns them as a JSON array string.protected abstract ElUpdates an existing element in the database (subclass hook).protected booleanReturns whether a missing `id` on creation must be rejected rather than auto-generated.Directly queries and retrieves the OrientDB element from the database.Queries and retrieves the OrientDB element from any database security context (bypassing RLS).voidPerforms runtime validation of mandatory and not-null schema constraints that cannot be enforced directly by OrientDB in distributed mode.org.gcube.com.fasterxml.jackson.databind.JsonNodeSerializes this element as an element of an Operation Envelope.org.gcube.com.fasterxml.jackson.databind.JsonNodeserializeAsEndpointReference(boolean includeMetadata, boolean includeContexts) Serializes this element as the endpoint reference of a Relation:type,supertypesandid, plusmetadataandcontextsonly when requested; never its custom fields nor its relations.org.gcube.com.fasterxml.jackson.databind.JsonNodeSerializes and returns the complete JSON representation of this element (including relationships).org.gcube.com.fasterxml.jackson.databind.JsonNodeSerializes and returns the raw/local JSON representation of this element (without relationships).voidMarks this management instance as the entry point of the operation.voidsetDryRun(boolean dryRun) Sets whether this operation should run as a dry run simulation.voidsetElement(El element) Binds an existing OrientDB element instance to this manager.voidsetElementType(String elementType) Sets the element schema type name.voidsetIgnoredFields(List<IgnoredFields> ignoredFields) Shares the collector of dropped fields with the management of an enclosing instance.voidSets the input JSON string representation of this element.voidsetJsonNode(org.gcube.com.fasterxml.jackson.databind.JsonNode jsonNode) Sets the input JSON representation node of this element.voidSets the pagination limit with safety validation.voidsetMaskMetadata(boolean maskMetadata) Sets whether privacy masking is enabled for metadata fields.voidsetMetadataPolicy(org.gcube.informationsystem.resourceregistry.api.rest.MetadataPolicy metadataPolicy) Sets the metadata projection policy.voidsetOClass(com.orientechnologies.orient.core.metadata.schema.OClass oClass) Sets the OrientDB schema class.voidsetODatabaseDocument(com.orientechnologies.orient.core.db.document.ODatabaseDocument oDatabaseDocument) Sets the active database connection document session.voidSets the pagination offset with safety validation.voidsetOperation(Operation operation) Sets the active operation type.voidsetPolymorphic(boolean polymorphic) Sets whether polymorphic queries are enabled.voidsetPreservePassedMetadata(boolean preservePassedMetadata) Sets whether a submittedmetadataobject is preserved as-is on create, instead of being autofilled from the current caller and clock.voidsetProperty(com.orientechnologies.orient.core.metadata.schema.OProperty oProperty, String key, org.gcube.com.fasterxml.jackson.databind.JsonNode value) Helper method to map and set a JSON property value onto the OrientDB vertex based on its schema type.voidsetReload(boolean reload) Sets whether to force a reload from the database.voidsetRequireExplicitUUID(boolean requireExplicitUUID) Sets whether a missing `id` on creation must be rejected rather than auto-generated.voidsetSanityCheckDeferred(boolean sanityCheckDeferred) Defers immediate sanity checks for atomic orchestration flows.voidsetUpdateMode(UpdateMode updateMode) Sets the update mode used by update operations.voidSets the UUID identifier of this element and validates it if a JSON node is already set.voidsetWorkingEnvironment(Environment workingContext) Sets the active database working environment.protected booleantypeSatified(String requiredType, String effectiveType) Validates whether the effective type satisfies the required type (supports schema inheritance).update()Updates the element in the database using the provided JSON representation.com.orientechnologies.orient.core.record.OElementupdateProperties(com.orientechnologies.orient.core.metadata.schema.OClass oClass, com.orientechnologies.orient.core.record.OElement element, org.gcube.com.fasterxml.jackson.databind.JsonNode jsonNode, Set<String> ignoreKeys, Set<String> ignoreStartWithKeys) Updates the properties of an OrientDBOElementfrom a JSON payload node.
-
Field Details
-
logger
protected org.slf4j.Logger loggerThe logger instance for auditing and diagnostics. -
DELETED
String constant representing deleted state.- See Also:
-
AT
Symbol constant for at.- See Also:
-
UNDERSCORE
Symbol constant for underscore.- See Also:
-
DOLLAR
Symbol constant for dollar.- See Also:
-
ignoreKeys
Keys to ignore during property mapping. -
ignoreStartWithKeys
Key prefixes to ignore during property mapping. -
elementClass
The specific class of the OrientDB element. -
accessType
protected final org.gcube.informationsystem.base.reference.AccessType accessTypeThe access type category. -
oDatabaseDocument
protected com.orientechnologies.orient.core.db.document.ODatabaseDocument oDatabaseDocumentThe active database document session. -
uuid
The UUID identifier of the element. -
jsonNode
protected org.gcube.com.fasterxml.jackson.databind.JsonNode jsonNodeThe input JSON payload node representing the element. -
oClass
protected com.orientechnologies.orient.core.metadata.schema.OClass oClassThe OrientDB schema class. -
typeName
The name of the schema type. -
self
protected org.gcube.com.fasterxml.jackson.databind.JsonNode selfThe serialized JSON node representing only the element's direct properties. -
complete
protected org.gcube.com.fasterxml.jackson.databind.JsonNode completeThe complete serialized JSON node representing the element and its relationships. -
cachedType
The cached schema type definition. -
element
The loaded OrientDB record element instance. -
reload
protected boolean reloadWhether to force a reload from the database. -
metadataPolicy
protected org.gcube.informationsystem.resourceregistry.api.rest.MetadataPolicy metadataPolicyMetadata projection policy for this management operation, set explicitly by the caller (typically the PEP layer). Whennull,shouldIncludeMetadataForCurrentNode()falls back toMetadataPolicy.DEFAULT; this class never resolves it from any ambient request context itself. -
limit
Pagination limit for list operations. -
offset
Pagination offset for list operations. -
maskMetadata
protected boolean maskMetadataWhentrue,metadata'screatedBy/lastUpdateByfields are privacy-masked (seeapplyPrivacyMask(ObjectNode)) while serializing this element. Set explicitly by the caller (typically the PEP layer, based on the requester's role); defaults tofalse(no masking). -
polymorphic
protected boolean polymorphicWhether the queries should include subclasses polymorphic results. -
entryPoint
protected boolean entryPointWhether this management instance is the entry point of the current operation, as opposed to a subordinated one triggered on a related instance during cascading.An operation can affect multiple instances (e.g. create, update, delete). Some follow-up actions must run only once per operation, on the entry point, rather than once per affected instance — for example, when a delete is invoked directly on a Resource, its sanity check must run once on the Resource itself, not be re-triggered by each of its describing Facets as they are cascaded into the same delete.
-
dryRun
protected boolean dryRunFlag indicating whether this operation is a simulation (dry run) which should end with a transaction rollback instead of a commit. -
sanityCheckDeferred
protected boolean sanityCheckDeferredDefers sanity checks for atomic orchestration flows that validate the final graph state explicitly before committing. -
preservePassedMetadata
protected boolean preservePassedMetadataWhentrue,internalCreate()preserves themetadataobject already present in the submitted JSON (creator, creation/last-update timestamps) instead of autofilling it from the current caller and clock. Used exclusively by System Restore to reproduce the original audit trail of a dumped instance. -
operation
It is assigned only in the entry point -
updateMode
Defines whether an update should merge into or replace the existing state. -
affectedInstances
Accumulates the UUID -> JSON representation of every instance actually affected by a Delete, addToContext, or removeFromContext cascade, so the caller can be told what changed (e.g. an Operation Envelope). Populated only when an instance's own processing completes successfully - post-order, at the end of the call.Not the same bookkeeping as the
visitedset inEntityManagement/RelationManagement:visitedis marked on entry, before recursing into children (pre-order), purely as an internal cycle guard, and is never reported to the caller. A UUID can be visited without ever becoming affected - e.g. a relation withaddConstraint=unpropagateis visited and skipped, never added, so it never appears here. -
ignoredFields
Collects the fields each written instance dropped because its category does not accept them. Shared by the managements of the instances nested in the same payload (seesetIgnoredFields(List)), so that the entry point reports them all. -
workingEnvironment
The active database working environment.
-
-
Constructor Details
-
ElementManagement
protected ElementManagement(org.gcube.informationsystem.base.reference.AccessType accessType) Creates a newElementManagementinstance for the specified access type.- Parameters:
accessType- the access type category of the element
-
ElementManagement
protected ElementManagement(org.gcube.informationsystem.base.reference.AccessType accessType, String typeName) Creates a newElementManagementinstance for the specified access type and type name.- Parameters:
accessType- the access type category of the elementtypeName- the name of the schema type
-
-
Method Details
-
isPolymorphic
public boolean isPolymorphic()Gets whether polymorphic queries are enabled.- Returns:
trueif polymorphic,falseotherwise
-
setPolymorphic
public void setPolymorphic(boolean polymorphic) Sets whether polymorphic queries are enabled.- Parameters:
polymorphic-trueto enable polymorphic results,falseotherwise
-
getLimit
Gets the pagination limit.- Returns:
- the limit
-
setLimit
Sets the pagination limit with safety validation.- Parameters:
limit- the pagination limit to set (-1 for unlimited)- Throws:
IllegalArgumentException- if the limit is less than -1
-
getOffset
Gets the pagination offset.- Returns:
- the offset
-
setOffset
Sets the pagination offset with safety validation.- Parameters:
offset- the pagination offset to set- Throws:
IllegalArgumentException- if the offset is less than 0
-
getMetadataPolicy
public org.gcube.informationsystem.resourceregistry.api.rest.MetadataPolicy getMetadataPolicy()Returns the metadata projection policy.- Returns:
- the metadata policy
-
setMetadataPolicy
public void setMetadataPolicy(org.gcube.informationsystem.resourceregistry.api.rest.MetadataPolicy metadataPolicy) Sets the metadata projection policy.- Parameters:
metadataPolicy- the metadata policy to set
-
isMaskMetadata
public boolean isMaskMetadata()Returns whether privacy masking is enabled for metadata fields.- Returns:
trueif masking is enabled,falseotherwise
-
setMaskMetadata
public void setMaskMetadata(boolean maskMetadata) Sets whether privacy masking is enabled for metadata fields.- Parameters:
maskMetadata-trueto enable masking,falseto disable
-
isPreservePassedMetadata
public boolean isPreservePassedMetadata()Returns whether a submittedmetadataobject is preserved as-is on create, instead of being autofilled from the current caller and clock.- Returns:
trueif passed metadata is preserved,falseotherwise
-
setPreservePassedMetadata
public void setPreservePassedMetadata(boolean preservePassedMetadata) Sets whether a submittedmetadataobject is preserved as-is on create, instead of being autofilled from the current caller and clock.- Parameters:
preservePassedMetadata-trueto preserve submitted metadata,falseto autofill
-
getAffectedInstances
Returns the map of instances affected by operations on this element.- Returns:
- the map of affected instances
-
getIgnoredFields
Returns the fields dropped by the instances written by this operation.- Returns:
- the dropped fields, one entry per instance that dropped any
-
setIgnoredFields
Shares the collector of dropped fields with the management of an enclosing instance.- Parameters:
ignoredFields- the collector of the enclosing management
-
addIgnoredFields
Records the fields this instance dropped, if any.- Parameters:
fields- the names of the dropped fields
-
setAsEntryPoint
public void setAsEntryPoint()Marks this management instance as the entry point of the operation. -
setOperation
Sets the active operation type.- Parameters:
operation- the operation type to set
-
getUpdateMode
Returns the update mode used by update operations.- Returns:
- the update mode
-
setUpdateMode
Sets the update mode used by update operations.- Parameters:
updateMode- the update mode to use;UpdateMode.MERGEwhen null
-
isSanityCheckDeferred
public boolean isSanityCheckDeferred()Returns whether sanity checks are deferred to the caller.- Returns:
trueif sanity checks are deferred
-
setSanityCheckDeferred
public void setSanityCheckDeferred(boolean sanityCheckDeferred) Defers immediate sanity checks for atomic orchestration flows.- Parameters:
sanityCheckDeferred-trueto defer sanity checks
-
cleanCachedSerialization
protected void cleanCachedSerialization()Invalidates the cached direct and complete JSON representations. -
getUUID
Returns the UUID identifier of this element.- Returns:
- the UUID identifier
-
isDryRun
public boolean isDryRun()Returns whether this operation is running as a dry run simulation.- Returns:
trueif dry run is enabled,falseotherwise
-
setDryRun
public void setDryRun(boolean dryRun) Sets whether this operation should run as a dry run simulation.- Parameters:
dryRun-trueto simulate the operation,falseto commit
-
concludeTransaction
Concludes the active database transaction. Commits the transaction if dryRun is disabled, or performs a rollback to simulate the changes if dryRun is enabled.- Parameters:
successMessage- the message to log upon successful commit
-
isReload
public boolean isReload()Returns whether to force a reload from the database.- Returns:
trueto force reload,falseotherwise
-
setReload
public void setReload(boolean reload) Sets whether to force a reload from the database.- Parameters:
reload-trueto force reload,falseotherwise
-
getAccessType
public org.gcube.informationsystem.base.reference.AccessType getAccessType()Returns the access type category of this element.- Returns:
- the access type category
-
getWorkingEnvironment
protected abstract Environment getWorkingEnvironment() throws org.gcube.informationsystem.resourceregistry.api.exceptions.ResourceRegistryExceptionReturns the active database working environment.- Returns:
- the working environment
- Throws:
org.gcube.informationsystem.resourceregistry.api.exceptions.ResourceRegistryException- if the environment cannot be resolved
-
setWorkingEnvironment
Sets the active database working environment.- Parameters:
workingContext- the working environment to set
-
setUUID
public void setUUID(UUID uuid) throws org.gcube.informationsystem.resourceregistry.api.exceptions.ResourceRegistryException Sets the UUID identifier of this element and validates it if a JSON node is already set.- Parameters:
uuid- the UUID to set- Throws:
org.gcube.informationsystem.resourceregistry.api.exceptions.ResourceRegistryException- if the UUID does not match the JSON node identifier
-
setJsonNode
public void setJsonNode(org.gcube.com.fasterxml.jackson.databind.JsonNode jsonNode) throws org.gcube.informationsystem.resourceregistry.api.exceptions.ResourceRegistryException Sets the input JSON representation node of this element.- Parameters:
jsonNode- the JSON node to set- Throws:
org.gcube.informationsystem.resourceregistry.api.exceptions.ResourceRegistryException- if the JSON structure is invalid
-
setJson
public void setJson(String json) throws org.gcube.informationsystem.resourceregistry.api.exceptions.ResourceRegistryException Sets the input JSON string representation of this element.- Parameters:
json- the JSON string to parse and set- Throws:
org.gcube.informationsystem.resourceregistry.api.exceptions.ResourceRegistryException- if the JSON string is invalid
-
setODatabaseDocument
public void setODatabaseDocument(com.orientechnologies.orient.core.db.document.ODatabaseDocument oDatabaseDocument) Sets the active database connection document session.- Parameters:
oDatabaseDocument- the database session
-
setOClass
public void setOClass(com.orientechnologies.orient.core.metadata.schema.OClass oClass) Sets the OrientDB schema class.- Parameters:
oClass- the schema class
-
getOClass
protected com.orientechnologies.orient.core.metadata.schema.OClass getOClass() throws org.gcube.informationsystem.resourceregistry.api.exceptions.types.SchemaException, org.gcube.informationsystem.resourceregistry.api.exceptions.ResourceRegistryExceptionReturns the schema class (OClass) associated with this element.- Returns:
- the OrientDB OClass
- Throws:
org.gcube.informationsystem.resourceregistry.api.exceptions.types.SchemaException- if the schema cannot be resolvedorg.gcube.informationsystem.resourceregistry.api.exceptions.ResourceRegistryException- on any database error
-
getCachedType
Returns the cached schema type definition, initializing it if not present.- Returns:
- the cached schema type definition
-
setElementType
public void setElementType(String elementType) throws org.gcube.informationsystem.resourceregistry.api.exceptions.ResourceRegistryException Sets the element schema type name.- Parameters:
elementType- the schema type name to set- Throws:
org.gcube.informationsystem.resourceregistry.api.exceptions.ResourceRegistryException- if the type name is empty or invalid
-
getTypeName
public String getTypeName() throws org.gcube.informationsystem.resourceregistry.api.exceptions.NotFoundException, org.gcube.informationsystem.resourceregistry.api.exceptions.instances.AvailableInAnotherContextException, org.gcube.informationsystem.resourceregistry.api.exceptions.ResourceRegistryExceptionReturns the canonical type name of the element.- Returns:
- the type name string
- Throws:
org.gcube.informationsystem.resourceregistry.api.exceptions.NotFoundException- if the element is not foundorg.gcube.informationsystem.resourceregistry.api.exceptions.instances.AvailableInAnotherContextException- if the element belongs to another contextorg.gcube.informationsystem.resourceregistry.api.exceptions.ResourceRegistryException- on database or lookup failure
-
checkJsonNode
protected void checkJsonNode() throws org.gcube.informationsystem.resourceregistry.api.exceptions.ResourceRegistryExceptionValidates the input JSON node and extracts the UUID and schema type.- Throws:
org.gcube.informationsystem.resourceregistry.api.exceptions.ResourceRegistryException- if the JSON structure is invalid or violates constraints
-
checkERMatch
protected void checkERMatch() throws org.gcube.informationsystem.resourceregistry.api.exceptions.ResourceRegistryExceptionValidates that the schema type of the JSON node matches the configured type name.- Throws:
org.gcube.informationsystem.resourceregistry.api.exceptions.ResourceRegistryException- if the schema types do not match
-
checkUUIDMatch
protected void checkUUIDMatch() throws org.gcube.informationsystem.resourceregistry.api.exceptions.ResourceRegistryExceptionValidates that the UUID inside the JSON node matches the configured element UUID.- Throws:
org.gcube.informationsystem.resourceregistry.api.exceptions.ResourceRegistryException- if the UUIDs do not match
-
serializeAsAffectedInstance
public org.gcube.com.fasterxml.jackson.databind.JsonNode serializeAsAffectedInstance() throws org.gcube.informationsystem.resourceregistry.api.exceptions.ResourceRegistryExceptionSerializes this element as an element of an Operation Envelope. Every element of the envelope is a root element, so therootmetadata and contexts policies enrich each of them; the cached representations are not touched.- Returns:
- the serialized JSON node representation
- Throws:
org.gcube.informationsystem.resourceregistry.api.exceptions.ResourceRegistryException- if serialization fails
-
serializeAsEndpointReference
public org.gcube.com.fasterxml.jackson.databind.JsonNode serializeAsEndpointReference(boolean includeMetadata, boolean includeContexts) throws org.gcube.informationsystem.resourceregistry.api.exceptions.ResourceRegistryException Serializes this element as the endpoint reference of a Relation:type,supertypesandid, plusmetadataandcontextsonly when requested; never its custom fields nor its relations.- Parameters:
includeMetadata- whether to includemetadata(masked as configured)includeContexts- whether to includecontexts- Returns:
- the endpoint reference
- Throws:
org.gcube.informationsystem.resourceregistry.api.exceptions.ResourceRegistryException- if serialization fails
-
serializeSelfAsJsonNode
public org.gcube.com.fasterxml.jackson.databind.JsonNode serializeSelfAsJsonNode() throws org.gcube.informationsystem.resourceregistry.api.exceptions.ResourceRegistryExceptionSerializes and returns the raw/local JSON representation of this element (without relationships).- Returns:
- the serialized JSON node representation
- Throws:
org.gcube.informationsystem.resourceregistry.api.exceptions.ResourceRegistryException- if serialization fails
-
createCompleteJsonNode
protected abstract org.gcube.com.fasterxml.jackson.databind.JsonNode createCompleteJsonNode() throws org.gcube.informationsystem.resourceregistry.api.exceptions.ResourceRegistryExceptionAbstract method to create the complete JSON node representation of the element.- Returns:
- the complete JSON node representing the element and its relationships
- Throws:
org.gcube.informationsystem.resourceregistry.api.exceptions.ResourceRegistryException- on serialization or mapping error
-
serializeAsJsonNode
public org.gcube.com.fasterxml.jackson.databind.JsonNode serializeAsJsonNode() throws org.gcube.informationsystem.resourceregistry.api.exceptions.ResourceRegistryExceptionSerializes and returns the complete JSON representation of this element (including relationships).- Returns:
- the serialized JSON node representation
- Throws:
org.gcube.informationsystem.resourceregistry.api.exceptions.ResourceRegistryException- if serialization fails
-
reallyCreate
protected abstract El reallyCreate() throws org.gcube.informationsystem.resourceregistry.api.exceptions.AlreadyPresentException, org.gcube.informationsystem.resourceregistry.api.exceptions.ResourceRegistryExceptionPersists a new element in the database (subclass hook).- Returns:
- the persisted OrientDB vertex
- Throws:
org.gcube.informationsystem.resourceregistry.api.exceptions.AlreadyPresentException- if the element already exists in the databaseorg.gcube.informationsystem.resourceregistry.api.exceptions.ResourceRegistryException- on any database error
-
requireExplicitUUID
protected boolean requireExplicitUUID()Returns whether a missing `id` on creation must be rejected rather than auto-generated.- Returns:
trueif a missing `id` must be rejected rather than auto-generated
-
setRequireExplicitUUID
public void setRequireExplicitUUID(boolean requireExplicitUUID) Sets whether a missing `id` on creation must be rejected rather than auto-generated.- Parameters:
requireExplicitUUID-trueto reject a missing `id` instead of auto-generating one
-
internalCreate
public El internalCreate() throws org.gcube.informationsystem.resourceregistry.api.exceptions.AlreadyPresentException, org.gcube.informationsystem.resourceregistry.api.exceptions.ResourceRegistryExceptionPerforms the internal database creation and registration of the element. Metadata is autofilled from the current caller and clock, unlessisPreservePassedMetadata()istrueand the submitted JSON already carries ametadataobject, in which case that object is persisted as-is.- Returns:
- the newly created OrientDB vertex
- Throws:
org.gcube.informationsystem.resourceregistry.api.exceptions.AlreadyPresentException- if the element already existsorg.gcube.informationsystem.resourceregistry.api.exceptions.ResourceRegistryException- on database or creation failure
-
checkUUIDNotAlreadyInUse
protected void checkUUIDNotAlreadyInUse() throws org.gcube.informationsystem.resourceregistry.api.exceptions.AlreadyPresentException, org.gcube.informationsystem.resourceregistry.api.exceptions.UUIDAlreadyInUseException, org.gcube.informationsystem.resourceregistry.api.exceptions.ResourceRegistryExceptionRejects UUID reuse before creating a brand-new element: a UUID is occupied by any element of any type in any Context, and a creation with an occupied UUID is a conflict. A UUID already bound to an element of the same type, in any Context, is anAlreadyPresentException; the same UUID bound to an element of a different type is aUUIDAlreadyInUseException.- Throws:
org.gcube.informationsystem.resourceregistry.api.exceptions.AlreadyPresentException- if an element of the same type already carries this UUIDorg.gcube.informationsystem.resourceregistry.api.exceptions.UUIDAlreadyInUseException- if the UUID is already bound to an element of a different typeorg.gcube.informationsystem.resourceregistry.api.exceptions.ResourceRegistryException- on database error
-
reallyUpdate
protected abstract El reallyUpdate() throws org.gcube.informationsystem.resourceregistry.api.exceptions.NotFoundException, org.gcube.informationsystem.resourceregistry.api.exceptions.ResourceRegistryExceptionUpdates an existing element in the database (subclass hook).- Returns:
- the updated OrientDB vertex
- Throws:
org.gcube.informationsystem.resourceregistry.api.exceptions.NotFoundException- if the element does not exist in the databaseorg.gcube.informationsystem.resourceregistry.api.exceptions.ResourceRegistryException- on any database error
-
internalUpdate
public El internalUpdate() throws org.gcube.informationsystem.resourceregistry.api.exceptions.NotFoundException, org.gcube.informationsystem.resourceregistry.api.exceptions.ResourceRegistryExceptionPerforms the internal database update and metadata refresh of the element.- Returns:
- the updated OrientDB vertex
- Throws:
org.gcube.informationsystem.resourceregistry.api.exceptions.NotFoundException- if the element does not existorg.gcube.informationsystem.resourceregistry.api.exceptions.ResourceRegistryException- on database or update failure
-
afterModification
protected void afterModification() throws org.gcube.informationsystem.resourceregistry.api.exceptions.ResourceRegistryExceptionCalled every time a write records on the element the caller and the time of its latest modification: the point where the modification is recorded on whatever else it modifies. Nothing by default.- Throws:
org.gcube.informationsystem.resourceregistry.api.exceptions.ResourceRegistryException- if the modification cannot be recorded
-
internalCreateOrUdate
public El internalCreateOrUdate() throws org.gcube.informationsystem.resourceregistry.api.exceptions.ResourceRegistryExceptionPerforms an internal idempotent database upsert (update if exists, otherwise create).- Returns:
- the created or updated OrientDB vertex
- Throws:
org.gcube.informationsystem.resourceregistry.api.exceptions.ResourceRegistryException- on database or upsert failure
-
reallyDelete
protected abstract void reallyDelete() throws org.gcube.informationsystem.resourceregistry.api.exceptions.NotFoundException, org.gcube.informationsystem.resourceregistry.api.exceptions.ResourceRegistryExceptionDeletes an existing element from the database (subclass hook).- Throws:
org.gcube.informationsystem.resourceregistry.api.exceptions.NotFoundException- if the element does not exist in the databaseorg.gcube.informationsystem.resourceregistry.api.exceptions.ResourceRegistryException- on any database error
-
internalDelete
public void internalDelete() throws org.gcube.informationsystem.resourceregistry.api.exceptions.NotFoundException, org.gcube.informationsystem.resourceregistry.api.exceptions.ResourceRegistryExceptionDeletes an existing element from the database.- Throws:
org.gcube.informationsystem.resourceregistry.api.exceptions.NotFoundException- if the element does not existorg.gcube.informationsystem.resourceregistry.api.exceptions.ResourceRegistryException- on database error
-
setElement
public void setElement(El element) throws org.gcube.informationsystem.resourceregistry.api.exceptions.ResourceRegistryException Binds an existing OrientDB element instance to this manager.- Parameters:
element- the OrientDB element to bind- Throws:
org.gcube.informationsystem.resourceregistry.api.exceptions.ResourceRegistryException- if the element is null or schema metadata lookup fails
-
getSpecificNotFoundException
protected abstract org.gcube.informationsystem.resourceregistry.api.exceptions.NotFoundException getSpecificNotFoundException(org.gcube.informationsystem.resourceregistry.api.exceptions.NotFoundException e) Converts a generic NotFoundException into a subclass-specific NotFoundException.- Parameters:
e- the generic exception- Returns:
- the specific NotFoundException
-
getSpecificAlreadyPresentException
protected abstract org.gcube.informationsystem.resourceregistry.api.exceptions.AlreadyPresentException getSpecificAlreadyPresentException(String message) Converts a generic AlreadyPresentException into a subclass-specific AlreadyPresentException.- Parameters:
message- the exception message- Returns:
- the specific AlreadyPresentException
-
getElement
public El getElement() throws org.gcube.informationsystem.resourceregistry.api.exceptions.NotFoundException, org.gcube.informationsystem.resourceregistry.api.exceptions.instances.AvailableInAnotherContextException, org.gcube.informationsystem.resourceregistry.api.exceptions.ResourceRegistryExceptionReturns the OrientDB element instance, retrieving and caching it if not already present.- Returns:
- the OrientDB element instance
- Throws:
org.gcube.informationsystem.resourceregistry.api.exceptions.NotFoundException- if the element does not existorg.gcube.informationsystem.resourceregistry.api.exceptions.instances.AvailableInAnotherContextException- if the element belongs to another contextorg.gcube.informationsystem.resourceregistry.api.exceptions.ResourceRegistryException- on database error
-
retrieveElement
public El retrieveElement() throws org.gcube.informationsystem.resourceregistry.api.exceptions.NotFoundException, org.gcube.informationsystem.resourceregistry.api.exceptions.ResourceRegistryExceptionDirectly queries and retrieves the OrientDB element from the database.- Returns:
- the loaded OrientDB element
- Throws:
org.gcube.informationsystem.resourceregistry.api.exceptions.NotFoundException- if the element does not existorg.gcube.informationsystem.resourceregistry.api.exceptions.ResourceRegistryException- on database error
-
retrieveElementFromAnyContext
public El retrieveElementFromAnyContext() throws org.gcube.informationsystem.resourceregistry.api.exceptions.NotFoundException, org.gcube.informationsystem.resourceregistry.api.exceptions.ResourceRegistryExceptionQueries and retrieves the OrientDB element from any database security context (bypassing RLS).- Returns:
- the loaded OrientDB element
- Throws:
org.gcube.informationsystem.resourceregistry.api.exceptions.NotFoundException- if the element does not existorg.gcube.informationsystem.resourceregistry.api.exceptions.ResourceRegistryException- on database error
-
reallyGetAll
public abstract String reallyGetAll() throws org.gcube.informationsystem.resourceregistry.api.exceptions.ResourceRegistryExceptionRetrieves all elements from the database and returns them as a JSON array string.- Returns:
- JSON array string of all elements
- Throws:
org.gcube.informationsystem.resourceregistry.api.exceptions.ResourceRegistryException- on database traversal or serialization error
-
getCurrentODatabaseDocumentFromThreadLocal
public static com.orientechnologies.orient.core.db.document.ODatabaseDocument getCurrentODatabaseDocumentFromThreadLocal()Returns theODatabaseDocumentcurrently bound to this thread by OrientDB's thread-local stack, ornullif no database is active on this thread.- Returns:
- the currently active ODatabaseDocument, or null
-
all
public String all() throws org.gcube.informationsystem.resourceregistry.api.exceptions.ResourceRegistryExceptionRetrieves and returns all elements of this type from the database as a JSON array string.- Returns:
- JSON array string representing all matching elements
- Throws:
org.gcube.informationsystem.resourceregistry.api.exceptions.ResourceRegistryException- if the database query fails
-
exists
public boolean exists() throws org.gcube.informationsystem.resourceregistry.api.exceptions.NotFoundException, org.gcube.informationsystem.resourceregistry.api.exceptions.instances.AvailableInAnotherContextException, org.gcube.informationsystem.resourceregistry.api.exceptions.ResourceRegistryExceptionReturns whether the element with the configured UUID exists in the database.- Returns:
trueif the element exists,falseotherwise- Throws:
org.gcube.informationsystem.resourceregistry.api.exceptions.NotFoundException- if the element does not existorg.gcube.informationsystem.resourceregistry.api.exceptions.instances.AvailableInAnotherContextException- if the element belongs to another contextorg.gcube.informationsystem.resourceregistry.api.exceptions.ResourceRegistryException- on database error
-
createOrUpdate
public String createOrUpdate() throws org.gcube.informationsystem.resourceregistry.api.exceptions.NotFoundException, org.gcube.informationsystem.resourceregistry.api.exceptions.instances.AvailableInAnotherContextException, org.gcube.informationsystem.resourceregistry.api.exceptions.ResourceRegistryExceptionAtomically creates or updates the element in the database (idempotent upsert).- Returns:
- the serialized JSON representation of the element
- Throws:
org.gcube.informationsystem.resourceregistry.api.exceptions.NotFoundException- if the element to update does not existorg.gcube.informationsystem.resourceregistry.api.exceptions.instances.AvailableInAnotherContextException- if the element belongs to another contextorg.gcube.informationsystem.resourceregistry.api.exceptions.ResourceRegistryException- on database error
-
createOrUpdateElementWithResult
public ElementCreationResult createOrUpdateElementWithResult() throws org.gcube.informationsystem.resourceregistry.api.exceptions.NotFoundException, org.gcube.informationsystem.resourceregistry.api.exceptions.instances.AvailableInAnotherContextException, org.gcube.informationsystem.resourceregistry.api.exceptions.ResourceRegistryExceptionAtomically creates or updates the element and preserves the resulting operation kind.- Returns:
- the serialized representation and whether a new element was created
- Throws:
org.gcube.informationsystem.resourceregistry.api.exceptions.NotFoundException- if the element to update does not existorg.gcube.informationsystem.resourceregistry.api.exceptions.instances.AvailableInAnotherContextException- if the element belongs to another contextorg.gcube.informationsystem.resourceregistry.api.exceptions.ResourceRegistryException- on database error
-
create
public String create() throws org.gcube.informationsystem.resourceregistry.api.exceptions.AlreadyPresentException, org.gcube.informationsystem.resourceregistry.api.exceptions.ResourceRegistryExceptionCreates a new element in the database.- Returns:
- the serialized JSON representation of the created element
- Throws:
org.gcube.informationsystem.resourceregistry.api.exceptions.AlreadyPresentException- if the element already existsorg.gcube.informationsystem.resourceregistry.api.exceptions.ResourceRegistryException- on database error
-
read
public String read() throws org.gcube.informationsystem.resourceregistry.api.exceptions.NotFoundException, org.gcube.informationsystem.resourceregistry.api.exceptions.instances.AvailableInAnotherContextException, org.gcube.informationsystem.resourceregistry.api.exceptions.ResourceRegistryExceptionReads and returns the complete serialized JSON string of the element.- Returns:
- the serialized JSON string representation of the element
- Throws:
org.gcube.informationsystem.resourceregistry.api.exceptions.NotFoundException- if the element does not existorg.gcube.informationsystem.resourceregistry.api.exceptions.instances.AvailableInAnotherContextException- if the element belongs to another contextorg.gcube.informationsystem.resourceregistry.api.exceptions.ResourceRegistryException- on database or read failure
-
update
public String update() throws org.gcube.informationsystem.resourceregistry.api.exceptions.NotFoundException, org.gcube.informationsystem.resourceregistry.api.exceptions.instances.AvailableInAnotherContextException, org.gcube.informationsystem.resourceregistry.api.exceptions.ResourceRegistryExceptionUpdates the element in the database using the provided JSON representation.- Returns:
- the serialized JSON string of the updated element
- Throws:
org.gcube.informationsystem.resourceregistry.api.exceptions.NotFoundException- if the element does not existorg.gcube.informationsystem.resourceregistry.api.exceptions.instances.AvailableInAnotherContextException- if the element belongs to another contextorg.gcube.informationsystem.resourceregistry.api.exceptions.ResourceRegistryException- on database or update failure
-
delete
public void delete() throws org.gcube.informationsystem.resourceregistry.api.exceptions.NotFoundException, org.gcube.informationsystem.resourceregistry.api.exceptions.instances.AvailableInAnotherContextException, org.gcube.informationsystem.resourceregistry.api.exceptions.types.SchemaViolationException, org.gcube.informationsystem.resourceregistry.api.exceptions.ResourceRegistryExceptionDeletes this element from the database.- Throws:
org.gcube.informationsystem.resourceregistry.api.exceptions.NotFoundException- if the element does not existorg.gcube.informationsystem.resourceregistry.api.exceptions.instances.AvailableInAnotherContextException- if the element belongs to another contextorg.gcube.informationsystem.resourceregistry.api.exceptions.types.SchemaViolationException- if deletion violates topological constraintsorg.gcube.informationsystem.resourceregistry.api.exceptions.ResourceRegistryException- on database error
-
isBackendLinkFieldName
Returns whether a name is reserved to the backend fields linking Entities and Relations:in,outand every name starting within_orout_, in lower or upper case. An instance of any category never stores a custom field so named.- Parameters:
name- the field name- Returns:
trueif the name is reserved
-
getPropertyMap
public Map<String,org.gcube.com.fasterxml.jackson.databind.JsonNode> getPropertyMap(org.gcube.com.fasterxml.jackson.databind.JsonNode jsonNode, Set<String> ignoreKeys, Set<String> ignoreStartWith) throws org.gcube.com.fasterxml.jackson.core.JsonProcessingException, IOException Extracts and returns a flat key-value map of properties from a JSON representation node, skipping any ignored keys and prefixes.- Parameters:
jsonNode- the JSON representation nodeignoreKeys- the set of keys to ignore/excludeignoreStartWith- the set of key prefixes to ignore/exclude- Returns:
- the mapped properties
- Throws:
org.gcube.com.fasterxml.jackson.core.JsonProcessingException- on Jackson parsing errorIOException- on stream reading error
-
setProperty
public void setProperty(com.orientechnologies.orient.core.metadata.schema.OProperty oProperty, String key, org.gcube.com.fasterxml.jackson.databind.JsonNode value) throws Exception Helper method to map and set a JSON property value onto the OrientDB vertex based on its schema type. A literal JSONnullremoves the property instead of being mapped to a value: underUpdateMode.MERGEper RFC 7396 §1, underUpdateMode.REPLACEbecause an explicitnullmeans the same as an omitted key.- Parameters:
oProperty- the schema property definitionkey- the property key stringvalue- the JSON value node to map- Throws:
Exception- if mapping or value assignment fails
-
updateProperties
public com.orientechnologies.orient.core.record.OElement updateProperties(com.orientechnologies.orient.core.metadata.schema.OClass oClass, com.orientechnologies.orient.core.record.OElement element, org.gcube.com.fasterxml.jackson.databind.JsonNode jsonNode, Set<String> ignoreKeys, Set<String> ignoreStartWithKeys) throws org.gcube.informationsystem.resourceregistry.api.exceptions.types.SchemaViolationException, org.gcube.informationsystem.resourceregistry.api.exceptions.ResourceRegistryException Updates the properties of an OrientDBOElementfrom a JSON payload node. UnderUpdateMode.REPLACE, property keys present on the element but omitted fromjsonNodeare removed. UnderUpdateMode.MERGE(the field's default, seeupdateMode), omitted keys are left untouched. In both modes a literal JSONnullremoves the property, as RFC 7396 §1 has it for a merge, and as an omitted key already does under a full replace. Callers whose update semantics are always full-replace (e.g. schema/type, Context, and Query Template updates) must callsetUpdateMode(UpdateMode)withUpdateMode.REPLACEbefore invoking this method, since the field otherwise defaults toMERGE.For a graph instance, the fields dropped because their name breaks the property naming rule (the reserved prefixes included) are recorded, those inside a nested
Propertyvalue in dot notation (seegetIgnoredFields()), a mandatory property left without a value by a creation or a replacement takes its declareddefaultValue, and an update that changes areadonlyproperty is a conflict.- Parameters:
oClass- the schema class of the elementelement- the OrientDB element to updatejsonNode- the input JSON payload nodeignoreKeys- the set of keys to ignore/excludeignoreStartWithKeys- the set of key prefixes to ignore/exclude- Returns:
- the updated OrientDB element
- Throws:
org.gcube.informationsystem.resourceregistry.api.exceptions.types.SchemaViolationException- if an update changes areadonlypropertyorg.gcube.informationsystem.resourceregistry.api.exceptions.ResourceRegistryException- on property setting or mapping error
-
applyPrivacyMask
public static org.gcube.com.fasterxml.jackson.databind.node.ObjectNode applyPrivacyMask(org.gcube.com.fasterxml.jackson.databind.node.ObjectNode metadataJson) Masks privacy-sensitive fields in the given metadata JSON node by replacingMetadata.CREATED_BY_PROPERTYandMetadata.LAST_UPDATE_BY_PROPERTYwith theElement.REDACTEDplaceholder.This method is
staticso it can be reused by other classes (e.g.,RedisContextCache) without duplicating the masking logic.Delegates to
applyPrivacyMask(ObjectNode, boolean)withkeepUserMeta=false, so all sensitive fields are always masked regardless of the current user's identity.- Parameters:
metadataJson- the metadata JSON node to mask.- Returns:
- the same
metadataJsoninstance, with privacy-sensitive fields replaced.
-
applyPrivacyMask
public static org.gcube.com.fasterxml.jackson.databind.node.ObjectNode applyPrivacyMask(org.gcube.com.fasterxml.jackson.databind.node.ObjectNode metadataJson, boolean keepUserMeta) Masks privacy-sensitive fields in the given metadata JSON node, with optional identity-aware behaviour controlled bykeepUserMeta.When
keepUserMetaisfalse, bothMetadata.CREATED_BY_PROPERTYandMetadata.LAST_UPDATE_BY_PROPERTYare unconditionally replaced withElement.REDACTED.When
keepUserMetaistrue, each field is only masked if its current value does not match the id of the calling user (retrieved fromSecretManagerProvider), so a user can always read their own entries in clear.This method has no cache dependency either way: every caller — both cached reads (e.g.
ContextRepository.filterContextNode(org.gcube.com.fasterxml.jackson.databind.node.ObjectNode, org.gcube.informationsystem.resourceregistry.contexts.ContextRepository.ContextProjection)) and live DB serialization (e.g.getPropertyForJson(String, Object)) — applies masking to a freshly fetched/copied node on each request, after the shared cache lookup, never before it; the shared caches themselves never store an already-masked value. SokeepUserMeta=truewould not leak between users even on a cached path. It is simply not wired to any caller yet: no REST/PEP layer currently requests a "reveal my own metadata" projection. Enabling it is caller-side work (threading a new projection flag from the PEP down to this call), not blocked on any caching-architecture change.- Parameters:
metadataJson- the metadata JSON node to mask.keepUserMeta- iftrue, fields matching the current user's id are left unmasked.- Returns:
- the same
metadataJsoninstance, with privacy-sensitive fields replaced where applicable.
-
getPropertyForJson
protected org.gcube.com.fasterxml.jackson.databind.JsonNode getPropertyForJson(String key, Object object) throws org.gcube.informationsystem.resourceregistry.api.exceptions.ResourceRegistryException Converts an OrientDB property value object into a JacksonJsonNodefor JSON serialization.- Parameters:
key- the name of the propertyobject- the database property value- Returns:
- the serialized JSON node, or null
- Throws:
org.gcube.informationsystem.resourceregistry.api.exceptions.ResourceRegistryException- if mapping or privacy filtering fails
-
getMandatoryErrorMessage
Formats and returns the error message for a missing mandatory field schema violation.- Parameters:
fieldName- the name of the mandatory field- Returns:
- the formatted error message
-
getMandatoryErrorMessage
Formats and returns the error message for a missing mandatory field of the given type.- Parameters:
typeName- the name of the type declaring the fieldfieldName- the name of the mandatory field- Returns:
- the formatted error message
-
typeSatified
protected boolean typeSatified(String requiredType, String effectiveType) throws org.gcube.informationsystem.resourceregistry.api.exceptions.types.SchemaException, org.gcube.informationsystem.resourceregistry.api.exceptions.ResourceRegistryException Validates whether the effective type satisfies the required type (supports schema inheritance).- Parameters:
requiredType- the required schema type nameeffectiveType- the effective schema type name- Returns:
trueif the effective type matches or extends the required type,falseotherwise- Throws:
org.gcube.informationsystem.resourceregistry.api.exceptions.types.SchemaException- if the schema type definitions are invalidorg.gcube.informationsystem.resourceregistry.api.exceptions.ResourceRegistryException- on database error
-
getAllProperties
protected Set<org.gcube.informationsystem.types.reference.properties.PropertyDefinition> getAllProperties() throws org.gcube.informationsystem.resourceregistry.api.exceptions.types.SchemaException, org.gcube.informationsystem.resourceregistry.api.exceptions.ResourceRegistryExceptionRetrieves and returns all property definitions for this schema type, including those inherited from all of its supertypes.- Returns:
- the set of all property definitions
- Throws:
org.gcube.informationsystem.resourceregistry.api.exceptions.types.SchemaException- if schema traversal failsorg.gcube.informationsystem.resourceregistry.api.exceptions.ResourceRegistryException- on database error
-
sanityCheck
public void sanityCheck() throws org.gcube.informationsystem.resourceregistry.api.exceptions.types.SchemaViolationException, org.gcube.informationsystem.resourceregistry.api.exceptions.ResourceRegistryExceptionPerforms runtime validation of mandatory and not-null schema constraints that cannot be enforced directly by OrientDB in distributed mode.- Throws:
org.gcube.informationsystem.resourceregistry.api.exceptions.types.SchemaViolationException- if a schema constraint is violatedorg.gcube.informationsystem.resourceregistry.api.exceptions.ResourceRegistryException- on database lookup failure
-