java.lang.Object
org.gcube.informationsystem.resourceregistry.persistence.orientdb.system.SystemRestoreManagement

public class SystemRestoreManagement extends Object
OrientDB-specific System Restore writes. A restore reproduces the archived state exactly: a Context comes back among the live Contexts or in the cemetery, as it was; a Resource or an IsRelatedTo is created in one of its Contexts with its original UUID, then the Context memberships of every instance the archive carries for it are set to the archived ones, without any propagation (the archive already holds the membership of each instance).

Every write sets ElementManagement.setPreservePassedMetadata(boolean), and the memberships are set without recording a modification: a restore is not a modification, so each restored instance keeps the metadata of the archive, whatever the number of Contexts it belongs to.

Author:
Luca Frosini (ISTI - CNR)
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    Re-creates a Context exactly as the archive carries it: in the cemetery when its state is deleted, among the live Contexts under its parent otherwise, with its original UUID, metadata, state, effectiveState, path, previousPaths and history.
    void
    Creates a new Query Template, preserving the original UUID and metadata from the submitted JSON.
    void
    createRelation(String json, UUID primaryContextUUID)
    Creates a new IsRelatedTo relation directly in the given Context, preserving the original UUID and metadata from the submitted JSON.
    void
    createResource(String json, UUID primaryContextUUID)
    Creates a new Resource (with embedded ConsistsOf/Facets) directly in the given Context, preserving the original UUID and metadata from the submitted JSON.
    void
    Drops the index of the UUID namespace shared by vertices and edges, before the Types of the archive are created: the creation of their classes cannot extend it.
    void
    Creates the UUID indexes again, once the Types of the archive exist and before any of its records is written.
    void
    Sets the Context memberships of an already-created instance, and of the ConsistsOf and Facet instances nested in its representation, to exactly the ones the archive carries for each of them: every instance is added to the archived Contexts it is not in and taken out of every other one, the Context it was created in included.

    Methods inherited from class java.lang.Object

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

    • SystemRestoreManagement

      public SystemRestoreManagement()
  • Method Details

    • createContext

      public void createContext(String json) throws org.gcube.informationsystem.resourceregistry.api.exceptions.ResourceRegistryException
      Re-creates a Context exactly as the archive carries it: in the cemetery when its state is deleted, among the live Contexts under its parent otherwise, with its original UUID, metadata, state, effectiveState, path, previousPaths and history.
      Parameters:
      json - the Context representation as produced by a System Dump
      Throws:
      org.gcube.informationsystem.resourceregistry.api.exceptions.ResourceRegistryException - if the creation fails
    • createResource

      public void createResource(String json, UUID primaryContextUUID) throws org.gcube.informationsystem.resourceregistry.api.exceptions.ResourceRegistryException
      Creates a new Resource (with embedded ConsistsOf/Facets) directly in the given Context, preserving the original UUID and metadata from the submitted JSON.
      Parameters:
      json - the Resource representation as produced by a System Dump
      primaryContextUUID - the Context in which the Resource is created
      Throws:
      org.gcube.informationsystem.resourceregistry.api.exceptions.ResourceRegistryException - if the creation fails
    • createRelation

      public void createRelation(String json, UUID primaryContextUUID) throws org.gcube.informationsystem.resourceregistry.api.exceptions.ResourceRegistryException
      Creates a new IsRelatedTo relation directly in the given Context, preserving the original UUID and metadata from the submitted JSON. Both source and target Resources must already exist in that Context.
      Parameters:
      json - the IsRelatedTo representation as produced by a System Dump
      primaryContextUUID - the Context in which the relation is created
      Throws:
      org.gcube.informationsystem.resourceregistry.api.exceptions.ResourceRegistryException - if the creation fails
    • createQueryTemplate

      public void createQueryTemplate(String json) throws org.gcube.informationsystem.resourceregistry.api.exceptions.ResourceRegistryException
      Creates a new Query Template, preserving the original UUID and metadata from the submitted JSON.
      Parameters:
      json - the Query Template representation as produced by a System Dump
      Throws:
      org.gcube.informationsystem.resourceregistry.api.exceptions.ResourceRegistryException - if the creation fails
    • dropSharedIdentifierIndex

      public void dropSharedIdentifierIndex() throws org.gcube.informationsystem.resourceregistry.api.exceptions.ResourceRegistryException
      Drops the index of the UUID namespace shared by vertices and edges, before the Types of the archive are created: the creation of their classes cannot extend it.
      Throws:
      org.gcube.informationsystem.resourceregistry.api.exceptions.ResourceRegistryException - if the index cannot be dropped
    • ensureIdentifierIndexes

      public void ensureIdentifierIndexes() throws org.gcube.informationsystem.resourceregistry.api.exceptions.ResourceRegistryException
      Creates the UUID indexes again, once the Types of the archive exist and before any of its records is written.
      Throws:
      org.gcube.informationsystem.resourceregistry.api.exceptions.ResourceRegistryException - if an index cannot be created
    • restoreMemberships

      public void restoreMemberships(String json) throws org.gcube.informationsystem.resourceregistry.api.exceptions.ResourceRegistryException
      Sets the Context memberships of an already-created instance, and of the ConsistsOf and Facet instances nested in its representation, to exactly the ones the archive carries for each of them: every instance is added to the archived Contexts it is not in and taken out of every other one, the Context it was created in included. No propagation constraint is evaluated and nothing is derived from the Resource: a Facet that was in fewer Contexts than its Resource comes back in those Contexts only. The metadata of every instance stay those of the archive.

      A relation is never left in a Context where its source or its target is not: such an archive is inconsistent, and the memberships of the instance are not written.

      Parameters:
      json - the Resource or IsRelatedTo representation as produced by a System Dump
      Throws:
      SystemRestoreArchiveException - if an instance of the representation carries no Context membership
      org.gcube.informationsystem.resourceregistry.api.exceptions.types.SchemaViolationException - if a relation is archived in a Context where one of its endpoints is not
      org.gcube.informationsystem.resourceregistry.api.exceptions.ResourceRegistryException - if the memberships cannot be established