Class SystemRestoreManagement
java.lang.Object
org.gcube.informationsystem.resourceregistry.persistence.orientdb.system.SystemRestoreManagement
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 -
Method Summary
Modifier and TypeMethodDescriptionvoidcreateContext(String json) Re-creates a Context exactly as the archive carries it: in the cemetery when itsstateisdeleted, among the live Contexts under itsparentotherwise, with its original UUID,metadata,state,effectiveState,path,previousPathsandhistory.voidcreateQueryTemplate(String json) Creates a new Query Template, preserving the original UUID and metadata from the submitted JSON.voidcreateRelation(String json, UUID primaryContextUUID) Creates a new IsRelatedTo relation directly in the given Context, preserving the original UUID and metadata from the submitted JSON.voidcreateResource(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.voidrestoreMemberships(String json) 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.
-
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 itsstateisdeleted, among the live Contexts under itsparentotherwise, with its original UUID,metadata,state,effectiveState,path,previousPathsandhistory.- 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 DumpprimaryContextUUID- 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 DumpprimaryContextUUID- 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
-
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. Themetadataof 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 membershiporg.gcube.informationsystem.resourceregistry.api.exceptions.types.SchemaViolationException- if a relation is archived in a Context where one of its endpoints is notorg.gcube.informationsystem.resourceregistry.api.exceptions.ResourceRegistryException- if the memberships cannot be established
-