ocfl

package
v3.0.9 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 10, 2026 License: Apache-2.0 Imports: 21 Imported by: 0

README

OCFL Core Packages

This directory contains the core packages of the gocfl project, which implement the OCFL (Oxford Common File Layout) specification.

Package Overview

The functionality is divided into several specialized packages covering different aspects of the OCFL specification:

Extension

The extension package provides core interfaces and management logic for OCFL extensions. Extensions are the official way to add additional functionality to OCFL objects and storage roots.

Factory

The factory module provides a unified factory mechanism to correctly instantiate components according to the various OCFL specification versions (e.g., 1.0, 1.1, 2.0).

OCFL High-Level API

The ocfl package itself (this directory) provides high-level functions for interacting with OCFL structures. It abstracts the complexity of version-specific instantiation and provides orchestrated actions for common tasks.

  • Initialization & Loading: LoadStorageRoot(...), InitStorageRoot(...), LoadObject(...), InitObject(...)
  • Actions: ValidateObject(...), Extract(...), ExtractMeta(...)
  • Factories: NewFactoryObject(...), NewFactoryStorageRoot(...)
Inventory

This package defines the structures and interfaces for the OCFL Inventory (inventory.json). It is the heart of an OCFL object and contains all metadata about versions, files, and fixity information.

Object

Manages the high-level operations of OCFL objects. While the inventory package focuses on data structures, object handles the loading, initializing, updating, and validating of objects.

StorageRoot

Manages the OCFL Storage Root, the top-level structure containing OCFL objects. It handles the Storage Layout and root-level extensions.

Validation

Provides structures and functions for handling OCFL validation errors and warnings according to the specification.


Utility Packages

  • ocflerrors: Central definition of OCFL-specific error types.
  • util: Helper functions for OCFL operations (e.g., version detection in the file system).
  • version: Definition of supported OCFL versions.

Documentation

Overview

Package ocfl provides high-level functions for interacting with OCFL objects. It orchestrates lower-level modules to perform common tasks like validating, extracting, and retrieving metadata from OCFL objects.

Package ocfl provides functions for loading and initializing OCFL storage roots and objects. It acts as a high-level entry point for working with different OCFL versions by orchestrating the creation of appropriate factories and managers.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Extract

func Extract(ctx context.Context, objectFS fs.FS, destFS appendfs.FS, path string, version *inventory.VersionNumber, withManifest bool, area string, logger ocfllogger.OCFLLogger) error

Extract retrieves the content of an OCFL object at the specified path and version, and writes it to the destination filesystem (destFS). If version is invalid or empty, the latest version is used. area specifies the storage area (e.g. "content" or "metadata") if applicable.

func ExtractMeta

func ExtractMeta(ctx context.Context, fsys fs.FS, path string, logger ocfllogger.OCFLLogger) (*inventory.Metadata, error)

ExtractMeta retrieves metadata information from an OCFL object at the given path. It returns a pointer to inventory.Metadata containing object details.

func InitObject

func InitObject(ctx context.Context, fsys appendfs.FS, extensionConfigFS fs.FS, ver version.OCFLVersion, id string, digest checksum.DigestAlgorithm, extensionParams map[string]string, logger ocfllogger.OCFLLogger) (object.Object, error)

InitObject initializes a new OCFL object with the given version, id and digest algorithm at fsys.

func InitStorageRoot

func InitStorageRoot(ctx context.Context, fsys appendfs.FS, extensionConfigFS fs.FS, ver version.OCFLVersion, digest checksum.DigestAlgorithm, params map[string]string, logger ocfllogger.OCFLLogger) (storageroot.StorageRoot, error)

InitStorageRoot initializes a new OCFL storage root with the given version at fsys.

func LoadObject

func LoadObject(ctx context.Context, fsys fs.FS, extensionParams map[string]string, logger ocfllogger.OCFLLogger) (object.Object, error)

LoadObject detects the OCFL version of the object at fsys, initializes the extension manager, and loads the object structure. It returns an object.Object instance.

func LoadStorageRoot

func LoadStorageRoot(ctx context.Context, fsys fs.FS, extensionParams map[string]string, conf map[storageroot.ConfigName]any, logger ocfllogger.OCFLLogger) (storageroot.StorageRoot, error)

LoadStorageRoot detects the OCFL version of the storage root at fsys, initializes the extension manager, and loads the storage root structure. The conf parameter allows passing configurations to the storage root factory (e.g. for storage root, initializer or loader). It returns a storageroot.StorageRoot instance.

func NewExtensionFactory

func NewExtensionFactory[T extension.ManagerCore[T]](
	params map[string]string,
	logger ocfllogger.OCFLLogger,
) (extension.Factory[T], error)

func NewFactoryObject

func NewFactoryObject(
	ver version.OCFLVersion,
	extensionFactory extension.Factory[object.ExtensionManager],
	logger ocfllogger.OCFLLogger,
) factory.FactoryObject

NewFactoryObject returns a FactoryObject for the specified OCFL version.

func NewFactoryStorageRoot

func NewFactoryStorageRoot(
	ver version.OCFLVersion,
	extensionFactory extension.Factory[storageroot.ExtensionManager],
	logger ocfllogger.OCFLLogger,
) factory.FactoryStorageRoot

NewFactoryStorageRoot returns a FactoryStorageRoot for the specified OCFL version.

func NewOCFLLogger

func NewOCFLLogger(ctx context.Context, logger zLogger.ZLogger, data map[string]string, ver version.OCFLVersion, validationStatus *validation.Status) ocfllogger.OCFLLogger

func SetupExtensionManager

func SetupExtensionManager[T extension.ManagerCore[T]](
	params map[string]string,
	fsys fs.FS,
	logger ocfllogger.OCFLLogger,
) (T, extension.Factory[T], error)

SetupExtensionManager initializes an extension factory and loads the extension manager from the provided filesystem. The function uses the type parameter T (usually storageroot.ExtensionManager or object.ExtensionManager) to instantiate the appropriate manager type. It takes configuration parameters, a filesystem containing extension configuration files, and a logger. It is intended to be called once for the storage root and once for objects to manage their respective extensions. Returns the loaded manager, the used factory, and any error encountered.

func ValidateObject

func ValidateObject(ctx context.Context, objectFS fs.FS, logger ocfllogger.OCFLLogger) error

ValidateObject validates an OCFL object located at objectFS. It loads the object and performs structural and fixity checks using the object's validator.

Types

This section is empty.

Directories

Path Synopsis
Package extension provides the basic interfaces and structures for OCFL extensions.
Package extension provides the basic interfaces and structures for OCFL extensions.
Package factory provides unified factory interfaces for creating OCFL objects and storage roots.
Package factory provides unified factory interfaces for creating OCFL objects and storage roots.
Package inventory defines the structures and interfaces for the OCFL (Oxford Common File Layout) Inventory.
Package inventory defines the structures and interfaces for the OCFL (Oxford Common File Layout) Inventory.
Package object contains the interfaces and implementations for OCFL objects.
Package object contains the interfaces and implementations for OCFL objects.
Package storageroot contains the interfaces and abstractions for managing OCFL (Oxford Common File Layout) storage roots.
Package storageroot contains the interfaces and abstractions for managing OCFL (Oxford Common File Layout) storage roots.
Package validation provides structures and functions for handling OCFL validation errors and warnings.
Package validation provides structures and functions for handling OCFL validation errors and warnings.
Package version defines the supported OCFL versions and provides utilities for version comparison and specification access.
Package version defines the supported OCFL versions and provides utilities for version comparison and specification access.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL