Class SystemRepository
java.lang.Object
org.gcube.informationsystem.resourceregistry.system.SystemRepository
Orchestrates database-agnostic System Dump and Restore operations for the complete logical
Resource Registry state.
Dump reads every collection unfiltered with full metadata (MetadataPolicy.ALL);
Restore validates the closed archive format before recreating that state.
- Author:
- Luca Frosini (ISTI - CNR)
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final StringZIP entry name for the Context hierarchy (live and cemetery).static final intFormat version of the produced dump archive, recorded inmanifest.json.static final StringZIP entry name for the dump manifest.static final StringZIP entry name for the Query Template collection.static final StringZIP entry name for the RegistryMetadata singleton.static final StringZIP entry name for the IsRelatedTo relation instance collection.static final StringZIP entry name for the Resource instance collection.static final StringZIP entry name for the Type schema dictionary. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoiddump(OutputStream outputStream) Writes a complete System Dump ZIP archive to the given output stream.Returns every Context, live and cemetery alike, unfiltered and unpaginated.Returns the dump manifest:DUMP_FORMAT_VERSIONand the creation timestamp (formatted perElement.DATETIME_PATTERN, matching every other date field in the dumped collections).Returns every Query Template, unfiltered and unpaginated.Returns theRegistryMetadatasingleton.Returns every IsRelatedTo relation instance, with full metadata and embedded Context membership.Returns every Resource instance, with embedded ConsistsOf/Facets, full metadata, and embedded Context membership.Returns every registered Type schema across the five dump root categories:Resource,Facet,IsRelatedTo,ConsistsOf, and every custom domainPropertydescendant, since a Facet's structure can reference a domain-specific Property type — e.g. gcube-model'sEnumStringPropertyorAttributeProperty— that a target must have registered before that Facet can be recreated), merged into a single JSON array.voidrestore(InputStream inputStream) Ingests a System Dump ZIP archive (as produced bydump(OutputStream)), recreating the entire Resource Registry state in strict topological order: Types, Contexts, Query Templates, Resources, then IsRelatedTo relations.
-
Field Details
-
DUMP_FORMAT_VERSION
public static final int DUMP_FORMAT_VERSIONFormat version of the produced dump archive, recorded inmanifest.json.- See Also:
-
MANIFEST_ENTRY
ZIP entry name for the dump manifest.- See Also:
-
REGISTRY_METADATA_ENTRY
ZIP entry name for the RegistryMetadata singleton.- See Also:
-
TYPES_ENTRY
ZIP entry name for the Type schema dictionary.- See Also:
-
CONTEXTS_ENTRY
ZIP entry name for the Context hierarchy (live and cemetery).- See Also:
-
QUERY_TEMPLATES_ENTRY
ZIP entry name for the Query Template collection.- See Also:
-
RESOURCES_ENTRY
ZIP entry name for the Resource instance collection.- See Also:
-
RELATIONS_ENTRY
ZIP entry name for the IsRelatedTo relation instance collection.- See Also:
-
-
Constructor Details
-
SystemRepository
public SystemRepository()
-
-
Method Details
-
dump
public void dump(OutputStream outputStream) throws org.gcube.informationsystem.resourceregistry.api.exceptions.ResourceRegistryException Writes a complete System Dump ZIP archive to the given output stream.- Parameters:
outputStream- the destination stream; not closed by this method's caller — the ZIP wrapper created here owns and closes it- Throws:
org.gcube.informationsystem.resourceregistry.api.exceptions.ResourceRegistryException- if any collection cannot be read
-
dumpManifest
public String dumpManifest() throws org.gcube.informationsystem.resourceregistry.api.exceptions.ResourceRegistryExceptionReturns the dump manifest:DUMP_FORMAT_VERSIONand the creation timestamp (formatted perElement.DATETIME_PATTERN, matching every other date field in the dumped collections). The model the dump conforms to is stated by the dumpedRegistryMetadata.- Returns:
- the manifest as a JSON object string
- Throws:
org.gcube.informationsystem.resourceregistry.api.exceptions.ResourceRegistryException- if the manifest cannot be serialized
-
dumpRegistryMetadata
public String dumpRegistryMetadata() throws org.gcube.informationsystem.resourceregistry.api.exceptions.ResourceRegistryExceptionReturns theRegistryMetadatasingleton.- Returns:
- the RegistryMetadata as a JSON object string
- Throws:
org.gcube.informationsystem.resourceregistry.api.exceptions.ResourceRegistryException- if the record cannot be read, or the system has none
-
dumpTypes
public String dumpTypes() throws org.gcube.informationsystem.resourceregistry.api.exceptions.ResourceRegistryExceptionReturns every registered Type schema across the five dump root categories:Resource,Facet,IsRelatedTo,ConsistsOf, and every custom domainPropertydescendant, since a Facet's structure can reference a domain-specific Property type — e.g. gcube-model'sEnumStringPropertyorAttributeProperty— that a target must have registered before that Facet can be recreated), merged into a single JSON array.- Returns:
- JSON array of every Type schema
- Throws:
org.gcube.informationsystem.resourceregistry.api.exceptions.ResourceRegistryException- if a root category cannot be read
-
dumpContexts
public String dumpContexts() throws org.gcube.informationsystem.resourceregistry.api.exceptions.ResourceRegistryExceptionReturns every Context, live and cemetery alike, unfiltered and unpaginated.- Returns:
- JSON array of every Context
- Throws:
org.gcube.informationsystem.resourceregistry.api.exceptions.ResourceRegistryException- if Contexts cannot be read
-
dumpQueryTemplates
public String dumpQueryTemplates() throws org.gcube.informationsystem.resourceregistry.api.exceptions.ResourceRegistryExceptionReturns every Query Template, unfiltered and unpaginated.- Returns:
- JSON array of every Query Template
- Throws:
org.gcube.informationsystem.resourceregistry.api.exceptions.ResourceRegistryException- if Query Templates cannot be read
-
dumpResources
public String dumpResources() throws org.gcube.informationsystem.resourceregistry.api.exceptions.ResourceRegistryExceptionReturns every Resource instance, with embedded ConsistsOf/Facets, full metadata, and embedded Context membership.- Returns:
- JSON array of every Resource
- Throws:
org.gcube.informationsystem.resourceregistry.api.exceptions.ResourceRegistryException- if instances cannot be read
-
dumpRelations
public String dumpRelations() throws org.gcube.informationsystem.resourceregistry.api.exceptions.ResourceRegistryExceptionReturns every IsRelatedTo relation instance, with full metadata and embedded Context membership.- Returns:
- JSON array of every IsRelatedTo relation
- Throws:
org.gcube.informationsystem.resourceregistry.api.exceptions.ResourceRegistryException- if instances cannot be read
-
restore
public void restore(InputStream inputStream) throws org.gcube.informationsystem.resourceregistry.api.exceptions.ResourceRegistryException Ingests a System Dump ZIP archive (as produced bydump(OutputStream)), recreating the entire Resource Registry state in strict topological order: Types, Contexts, Query Templates, Resources, then IsRelatedTo relations. Every original UUID and every originalmetadataobject (creator, creation/last-update timestamps) is preserved verbatim. The RegistryMetadata is written last, as dumped, exceptrevisionCount, which stays the target's: the restored Types counted as runtime creates, and the counter never goes backwards at runtime.Assumes the target system is empty: no attempt is made to merge with, or skip conflicts against, pre-existing data.
- Parameters:
inputStream- the ZIP archive stream- Throws:
org.gcube.informationsystem.resourceregistry.api.exceptions.ResourceRegistryException- if the archive is malformed, of an unsupported format version, or any collection cannot be restored
-