gocfl / ocfl / extensions
OCFL is designed so that the core standard remains lean and stable, while specific functionalities are represented through extensions. These make it possible to customize the behavior of the archive without jeopardizing basic compatibility.
Extensions are located in both the storage root and the individual OCFL objects in the respective extensions/ directory.
0004-hashed-n-tuple-storage-layout).NNNN- and are specific to a tool or an institution. gocfl uses these extensively for its additional functions.As we saw during the initialization of the storage root, gocfl automatically creates configuration directories. A detailed overview of the extensions used in this workshop can be found here:
The implementation of extensions in gocfl is based on various call points (hooks) where the logic of the extension intervenes in the OCFL workflow. If an interface has multiple hooks, an extension using it must implement all the hooks defined therein.
These differ depending on the context:
objectExtension.go.
ExtensionObjectContentPath:
BuildObjectManifestPath: Creates the path for the manifest within the object.ExtensionObjectExtractPath:
BuildObjectExtractPath: Defines paths for extracting content.ExtensionObjectStatePath:
BuildObjectStatePath: Controls path creation in the object state.ExtensionArea:
GetAreaPath: Provides the path for a specific storage area.ExtensionStream:
StreamObject: Allows reading the data stream.ExtensionContentChange:
AddFileBefore: Before adding a file.UpdateFileBefore: Before updating a file.DeleteFileBefore: Before deleting a file.AddFileAfter: After adding a file.UpdateFileAfter: After updating a file.DeleteFileAfter: Actions after deleting a file.ExtensionObjectChange:
UpdateObjectBefore: Actions before manifest creation / object update.UpdateObjectAfter: Actions after saving the object.ExtensionFixityDigest:
GetFixityDigests: Provides additional digest algorithms for fixity checks.ExtensionMetadata:
GetMetadata: Provides additional metadata for the object.ExtensionVersionDone:
VersionDone: Called when a new version is completely finished.ExtensionNewVersion:
NeedNewVersion: Checks if a new version is required.DoNewVersion: Performs initializations for a new version.storagerootExtension.go.
ExtensionBuildStorageRootPath:
BuildStorageRootPath: Calculation of the physical path of an object based on its ID (Storage Layout).The NNNN-gocfl-extension-manager uses specific keys in its config.json to address the various extension types. Here is the mapping of the Go interfaces to the configuration entries:
| Interface | Key in config.json |
|---|---|
ExtensionBuildStorageRootPath |
StorageRootPath |
ExtensionObjectContentPath |
ObjectContentPath |
ExtensionObjectExtractPath |
ObjectExtractPath |
ExtensionObjectStatePath |
ObjectStatePath |
ExtensionArea |
Area |
ExtensionStream |
Stream |
ExtensionContentChange |
ContentChange |
ExtensionObjectChange |
ObjectChange |
ExtensionFixityDigest |
FixityDigest |
ExtensionMetadata |
Metadata |
ExtensionNewVersion |
NewVersion |
ExtensionVersionDone |
VersionDone |
An important aspect of gocfl is that for every enabled extension, the corresponding documentation should be copied directly into the storage root as a Markdown file (e.g., NNNN-gocfl-extension-manager.md).
This guarantees that even in decades, it will still be possible to understand which rules applied to the storage and processing of the data, even if the original software or website no longer exists.
| Back to Table of Contents | Next Topic: Creating Objects |