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

public class RegistryMetadataStore extends Object
Reads and changes the RegistryMetadata singleton at runtime, each operation in a session of its own, with the Type environment's users: whoever works on types reads the schema version with them. Every change is a single server-side update of the fields it touches.
Author:
Luca Frosini (ISTI - CNR)
  • Constructor Details

    • RegistryMetadataStore

      public RegistryMetadataStore()
  • Method Details

    • read

      public org.gcube.informationsystem.registry.RegistryMetadata read() throws org.gcube.informationsystem.resourceregistry.api.exceptions.ResourceRegistryException
      Reads the whole record.
      Returns:
      the record, or null if none exists
      Throws:
      org.gcube.informationsystem.resourceregistry.api.exceptions.ResourceRegistryException - if the database cannot be read
    • readRevisionCount

      public Long readRevisionCount() throws org.gcube.informationsystem.resourceregistry.api.exceptions.ResourceRegistryException
      Reads revisionCount.
      Returns:
      the current value, or null if no record exists
      Throws:
      org.gcube.informationsystem.resourceregistry.api.exceptions.ResourceRegistryException - if the database cannot be read
    • incrementRevisionCount

      public Long incrementRevisionCount(String modelName) throws org.gcube.informationsystem.resourceregistry.api.exceptions.ResourceRegistryException
      Advances the global revisionCount, and the given model's, by one.
      Parameters:
      modelName - the model the written type belongs to, or null for the global counter alone
      Returns:
      the new global value, or null if no record exists
      Throws:
      org.gcube.informationsystem.resourceregistry.api.exceptions.ResourceRegistryException - if the database cannot be written
    • modelOf

      public String modelOf(String typeName) throws org.gcube.informationsystem.resourceregistry.api.exceptions.ResourceRegistryException
      Returns the model a type belongs to.
      Parameters:
      typeName - the type name
      Returns:
      the model name, or null if no model holds the type or no record exists
      Throws:
      org.gcube.informationsystem.resourceregistry.api.exceptions.ResourceRegistryException - if the database cannot be read
    • putRuntimeType

      public boolean putRuntimeType(String typeName, String version) throws org.gcube.informationsystem.resourceregistry.api.exceptions.ResourceRegistryException
      Records a type created at runtime in the runtime model.
      Parameters:
      typeName - the type name
      version - the type version
      Returns:
      true if recorded, false if no record or no runtime model exists
      Throws:
      org.gcube.informationsystem.resourceregistry.api.exceptions.ResourceRegistryException - if the database cannot be written
    • alignRuntimeType

      public boolean alignRuntimeType(String typeName, String version) throws org.gcube.informationsystem.resourceregistry.api.exceptions.ResourceRegistryException
      Aligns the version of a runtime type, if the type is one: the types of the classpath models are a snapshot of their libraries and never change at runtime.
      Parameters:
      typeName - the type name
      version - the type version
      Returns:
      true if the type is a runtime type and its version was aligned
      Throws:
      org.gcube.informationsystem.resourceregistry.api.exceptions.ResourceRegistryException - if the database cannot be written
    • removeRuntimeType

      public boolean removeRuntimeType(String typeName) throws org.gcube.informationsystem.resourceregistry.api.exceptions.ResourceRegistryException
      Removes a runtime type, if the type is one.
      Parameters:
      typeName - the type name
      Returns:
      true if the type was a runtime type and was removed
      Throws:
      org.gcube.informationsystem.resourceregistry.api.exceptions.ResourceRegistryException - if the database cannot be written