Documentation ¶
Overview ¶
Package metadata contains facilities for working with OCFL object metadata. At the moment, it is mostly a 1:1 reflection inventory.json files.
One notable exception is the File type, which consolidates information derivable from the Inventory via joins, e.g. the physical paths, logical paths, and fixity for individual files within versions. A convenience method will generate File metadata when desired.
It may be necessary at some point to develop additional abstractions on OCFL metadata when considering alternate source such as databases, which are not structured like an inventory.json file
Index ¶
Constants ¶
const InventoryFile = "inventory.json"
InventoryFile contains the name of OCFL inventory files
const InventoryType = "https://ocfl.io/1.0/spec/#inventory"
InventoryType contains the expected "type" value of an OCFL object
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Digest ¶
type Digest string
Digest is a lowercase hex string representing a digest, as defined by inventory.json in the OCFL spec
type DigestAlgorithm ¶
type DigestAlgorithm string
DigestAlgorithm is identifier for an ocfl-approved digest algorithm, as defined by inventory.json in the OCFL spec
type File ¶
type File struct { Version *Version Inventory *Inventory LogicalPath string PhysicalPath string Fixity map[DigestAlgorithm]Digest }
File describes individual files within an OCFL object. It is constructed from the contents if an OCFL inventory, but is not directly defined by it.
type Fixity ¶
type Fixity map[DigestAlgorithm]Manifest
Fixity is a map of digest algorithms to digests to paths, as defined by inventory.json in the OCFL spec
type Inventory ¶
type Inventory struct { ID string `json:"id"` Type string `json:"type"` DigestAlgorithm DigestAlgorithm `json:"digestAlgorithm"` Head string `json:"head"` Manifest Manifest `json:"manifest"` Versions map[string]Version `json:"versions"` Fixity Fixity `json:"fixity"` // contains filtered or unexported fields }
Inventory defines the contents of an OCFL object, as defined by inventory.json in the OCFL spec
func NewInventory ¶
NewInventory creates a new, empty inventory with reasonable defaults: sha512 digest algorithm (can be changed by callee if need be), with an empty "v1" version. The manifest and v1's state are initialized with empty maps.
func (*Inventory) DeleteFile ¶ added in v0.2.0
func (*Inventory) Files ¶
Files consolidates metadata for each logical file in a version
We want a physical path for every logical file in a version. However, there may be none (inconsistent manifest), or several (allowed by OCFL). This function returns the "newest" one corresponding to the given version. That is to say, if the manifest lists [v1/content/foo.txt, v2/content/foo.txt, v3/content/foo.txt] as having the same hash, and the given version is v2, then it'll return v2/foo.txt
func (*Inventory) PutFile ¶
PutFile adds a logical file to the OCFL manifest and HEAD version state, overwriting any existing entries if present.
func (*Inventory) Validate ¶
Validate verifies whether inventory metadata is internally consistent and allowable by the OCFL spec A positive result (no error returned) means only that a given manifest reflects a plausible internal state. It does not imply that the files referenced by the manifest actually exist, or match their claimed checksums, etc.
Internally consistent ¶
Internally consistent means:
All required values are present.
All entities Manifest are referenced in the state of some version (i.e. there are no unused entities present in the manifest).
All State entries have a corresponding Manifest entry (i.e. State cannot reference content that is not in the manifest).
A single physical file path has at most one digest for each allowable OCFL digest type. (i.e. the path doesn't have conflicting digests in the manifest or fixity sections)
A single logical file path within a version has exactly one digest (i.e. a path doesn't appear twice within the state of a given version, with different digests).
Head points to a version defined in the inventory, and that version is the highest.
Digest values match the length and composition implied by their algorithm.
Version numbers increase monotonically, and have the same zero padding convention
type Manifest ¶
Manifest is a mapping of digests to physical file paths, as defined by inventory.json in the OCFL spec
type Version ¶
type Version struct { Created time.Time `json:"created"` Message string `json:"message"` User User `json:"user"` State Manifest `json:"state"` Type string `json:"type"` }
Version contains ocfl version metadata, as defined by inventory.json in the OCFL spec
type VersionID ¶
type VersionID string
VersionID contains a version ID representation as consistent with the OCFL spec. It starts with v, may be zero padded, etc.
func (VersionID) Increment ¶
Increment increments an OCFL version, respecting padding if a given version ID is padded