java.lang.Object
org.gcube.informationsystem.resourceregistry.persistence.orientdb.utils.MetadataUtility

public class MetadataUtility extends Object
Author:
Luca Frosini (ISTI - CNR)
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    static org.gcube.informationsystem.base.reference.properties.Metadata
    addMetadata(com.orientechnologies.orient.core.record.OElement element)
    Creates new metadata and attaches it to the specified OrientDB element.
    static org.gcube.informationsystem.base.reference.properties.Metadata
    Creates and initializes a new Metadata instance with the current creator, last updater, and creation/last-update timestamps.
    static org.gcube.informationsystem.base.reference.properties.Metadata
    getMetadata(com.orientechnologies.orient.core.record.OElement element)
    Reads and returns the Metadata associated with the specified OrientDB element.
    static org.gcube.informationsystem.base.reference.properties.Metadata
    getMetadata(org.gcube.com.fasterxml.jackson.databind.JsonNode jsonNode)
    Deserializes and returns the Metadata instance from the specified JSON node.
    getMetadataOrient(com.orientechnologies.orient.core.record.impl.ODocument oDocument)
    Extracts and converts an OrientDB ODocument into a strongly-typed MetadataOrient instance.
    static String
    Retrieves and returns the current authenticated username from the SecretManager.
    static void
    updateModifiedByAndLastUpdate(com.orientechnologies.orient.core.record.OElement element)
    Updates the modification metadata (last update user and last update time) for the specified element.

    Methods inherited from class java.lang.Object

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

    • MetadataUtility

      public MetadataUtility()
  • Method Details

    • getUser

      public static String getUser()
      Retrieves and returns the current authenticated username from the SecretManager.
      Returns:
      the resolved username, or Element.UNKNOWN_USER if not available
    • createMetadata

      public static org.gcube.informationsystem.base.reference.properties.Metadata createMetadata()
      Creates and initializes a new Metadata instance with the current creator, last updater, and creation/last-update timestamps.
      Returns:
      the initialized metadata instance
    • getMetadata

      public static org.gcube.informationsystem.base.reference.properties.Metadata getMetadata(org.gcube.com.fasterxml.jackson.databind.JsonNode jsonNode) throws org.gcube.com.fasterxml.jackson.core.JsonParseException, org.gcube.com.fasterxml.jackson.databind.JsonMappingException, IOException, org.gcube.informationsystem.resourceregistry.api.exceptions.ResourceRegistryException
      Deserializes and returns the Metadata instance from the specified JSON node.
      Parameters:
      jsonNode - the JSON node containing metadata property
      Returns:
      the deserialized metadata instance, or null if not found or null
      Throws:
      org.gcube.com.fasterxml.jackson.core.JsonParseException - on JSON syntax error
      org.gcube.com.fasterxml.jackson.databind.JsonMappingException - on Jackson object mapping error
      IOException - on input/output stream failure
      org.gcube.informationsystem.resourceregistry.api.exceptions.ResourceRegistryException - on internal registry serialization error
    • getMetadataOrient

      public static MetadataOrient getMetadataOrient(com.orientechnologies.orient.core.record.impl.ODocument oDocument) throws org.gcube.informationsystem.resourceregistry.api.exceptions.ResourceRegistryException
      Extracts and converts an OrientDB ODocument into a strongly-typed MetadataOrient instance.
      Parameters:
      oDocument - the OrientDB document to convert
      Returns:
      the matching MetadataOrient instance
      Throws:
      org.gcube.informationsystem.resourceregistry.api.exceptions.ResourceRegistryException - if the metadata reconstruction fails
    • addMetadata

      public static org.gcube.informationsystem.base.reference.properties.Metadata addMetadata(com.orientechnologies.orient.core.record.OElement element)
      Creates new metadata and attaches it to the specified OrientDB element.
      Parameters:
      element - the OrientDB element to enrich
      Returns:
      the created metadata instance
    • getMetadata

      public static org.gcube.informationsystem.base.reference.properties.Metadata getMetadata(com.orientechnologies.orient.core.record.OElement element) throws org.gcube.informationsystem.resourceregistry.api.exceptions.ResourceRegistryException
      Reads and returns the Metadata associated with the specified OrientDB element.
      Parameters:
      element - the OrientDB element to inspect
      Returns:
      the retrieved metadata instance
      Throws:
      org.gcube.informationsystem.resourceregistry.api.exceptions.ResourceRegistryException - if the lookup fails
    • updateModifiedByAndLastUpdate

      public static void updateModifiedByAndLastUpdate(com.orientechnologies.orient.core.record.OElement element) throws org.gcube.informationsystem.resourceregistry.api.exceptions.ResourceRegistryException
      Updates the modification metadata (last update user and last update time) for the specified element.
      Parameters:
      element - the OrientDB element to update
      Throws:
      org.gcube.informationsystem.resourceregistry.api.exceptions.ResourceRegistryException - if the update fails