Documentation
¶
Overview ¶
Package ocfl for manipulating and checking Oxford Common Filesystem Layout This Oxford Common File Layout (OCFL) specification describes an application-independent approach to the storage of digital information in a structured, transparent, and predictable manner. It is designed to promote long-term object management best practices within digital repositories. https://ocfl.io
Index ¶
- Constants
- Variables
- func CleanPath(fname string, MaxFilenameLength, MaxPathnameLength int) (string, error)
- func FixFilename(fname string) string
- func Fullpath(path string) (string, error)
- func GetErrorStacktrace(err error) errors.StackTrace
- func InventoryIsEqual(i1, i2 Inventory) bool
- func NewContextValidation(parent context.Context) context.Context
- func ReadFile(object Object, name, version, storageType, storageName string, fsys fs.FS) ([]byte, error)
- func ReadJsonL(object Object, name, version, compress, storageType, storageName string, ...) ([]byte, error)
- func SpecIsLessOrEqual(s1, s2 InventorySpec) bool
- func ValidVersion(version OCFLVersion) bool
- func WriteJsonL(object Object, name string, brotliData []byte, ...) error
- type Extension
- type ExtensionArea
- type ExtensionConfig
- type ExtensionContentChange
- type ExtensionExternalParam
- type ExtensionFactory
- func (f *ExtensionFactory) AddCreator(name string, creator creatorFunc)
- func (f *ExtensionFactory) AddObjectDefaultExtension(ext Extension)
- func (f *ExtensionFactory) AddStorageRootDefaultExtension(ext Extension)
- func (f *ExtensionFactory) Create(fsys fs.FS) (Extension, error)
- func (f *ExtensionFactory) CreateExtensions(fsys fs.FS, validation Validation) (ExtensionManager, error)
- func (f *ExtensionFactory) LoadExtensions(fsys fs.FS, validation Validation) (ExtensionManager, error)
- type ExtensionFixityDigest
- type ExtensionInitial
- type ExtensionManager
- type ExtensionManagerConfig
- type ExtensionMetadata
- type ExtensionNewVersion
- type ExtensionObjectChange
- type ExtensionObjectContentPath
- type ExtensionObjectExtractPath
- type ExtensionObjectStatePath
- type ExtensionStorageRootPath
- type ExtensionStream
- type FileMetadata
- type Fixity
- type InitialDummy
- func (dummy *InitialDummy) GetConfig() any
- func (dummy *InitialDummy) GetConfigString() string
- func (dummy *InitialDummy) GetFS() fs.FS
- func (dummy *InitialDummy) GetName() string
- func (dummy *InitialDummy) IsRegistered() bool
- func (dummy *InitialDummy) SetFS(fsys fs.FS, create bool)
- func (dummy *InitialDummy) SetParams(params map[string]string) error
- func (dummy *InitialDummy) Terminate() error
- func (dummy *InitialDummy) WriteConfig() error
- type Inventory
- type InventoryBase
- func (i *InventoryBase) AddFile(stateFilenames []string, manifestFilename string, ...) error
- func (i *InventoryBase) AlreadyExists(stateFilename, checksum string) (bool, error)
- func (i *InventoryBase) BuildManifestName(stateFilename string) string
- func (i *InventoryBase) BuildManifestNameVersion(stateFilename string, version string) string
- func (i *InventoryBase) CheckFiles(fileManifest map[checksum.DigestAlgorithm]map[string][]string) error
- func (i *InventoryBase) Clean() error
- func (i *InventoryBase) CopyFile(dest string, digest string) error
- func (i *InventoryBase) DeleteFile(stateFilename string) error
- func (i *InventoryBase) Finalize(inCreation bool) (err error)
- func (i *InventoryBase) GetContentDir() string
- func (i *InventoryBase) GetDigestAlgorithm() checksum.DigestAlgorithm
- func (i *InventoryBase) GetDuplicates(checksum string) []string
- func (i *InventoryBase) GetFiles() map[string][]string
- func (i *InventoryBase) GetFilesFlat() []string
- func (i *InventoryBase) GetFixity() Fixity
- func (i *InventoryBase) GetFixityDigestAlgorithm() []checksum.DigestAlgorithm
- func (i *InventoryBase) GetHead() string
- func (i *InventoryBase) GetID() string
- func (i *InventoryBase) GetManifest() map[string][]string
- func (i *InventoryBase) GetRealContentDir() string
- func (i *InventoryBase) GetSpec() InventorySpec
- func (i *InventoryBase) GetStateFiles(version string, cs string) ([]string, error)
- func (i *InventoryBase) GetVersionStrings() []string
- func (i *InventoryBase) GetVersions() map[string]*Version
- func (i *InventoryBase) Init(id string, digest checksum.DigestAlgorithm, fixity []checksum.DigestAlgorithm) (err error)
- func (i *InventoryBase) IsModified() bool
- func (i *InventoryBase) IsUpdate(virtualFilename, checksum string) (bool, error)
- func (i *InventoryBase) IsWriteable() bool
- func (i *InventoryBase) IterateStateFiles(version string, fn StateFileCallback) error
- func (i *InventoryBase) NewVersion(msg, UserName, UserAddress string) error
- func (i *InventoryBase) RenameFile(stateSource, stateDest string) error
- func (i *InventoryBase) VersionLessOrEqual(v1, v2 string) bool
- type InventorySpec
- type InventoryV1_0
- type InventoryV1_1
- type NamesStruct
- type OCFLManifest
- type OCFLState
- type OCFLString
- type OCFLTime
- type OCFLUser
- type OCFLVersion
- type OCFLVersions
- type Object
- type ObjectBase
- func (object *ObjectBase) AddData(data []byte, path string, checkDuplicate bool, area string, ...) error
- func (object *ObjectBase) AddFile(fsys fs.FS, versionFS fs.FS, path string, checkDuplicate bool, area string, ...) error
- func (object *ObjectBase) AddFolder(fsys fs.FS, versionFS fs.FS, checkDuplicate bool, area string) error
- func (object *ObjectBase) AddReader(r io.ReadCloser, files []string, area string, noExtensionHook bool, isDir bool) (string, error)
- func (object *ObjectBase) BeginArea(area string)
- func (object *ObjectBase) BuildNames(files []string, area string) (*NamesStruct, error)
- func (object *ObjectBase) Check() error
- func (object *ObjectBase) Close() error
- func (object *ObjectBase) CreateInventory(id string, digest checksum.DigestAlgorithm, fixity []checksum.DigestAlgorithm) (Inventory, error)
- func (object *ObjectBase) DeleteFile(virtualFilename string, digest string) error
- func (object *ObjectBase) EndArea() error
- func (object *ObjectBase) EndUpdate() error
- func (object *ObjectBase) Extract(fsys fs.FS, version string, withManifest bool, area string) error
- func (object *ObjectBase) GetAreaPath(area string) (string, error)
- func (object *ObjectBase) GetDigestAlgorithm() checksum.DigestAlgorithm
- func (object *ObjectBase) GetExtensionManager() ExtensionManager
- func (object *ObjectBase) GetFS() fs.FS
- func (object *ObjectBase) GetID() string
- func (object *ObjectBase) GetInventory() Inventory
- func (object *ObjectBase) GetMetadata() (*ObjectMetadata, error)
- func (object *ObjectBase) GetVersion() OCFLVersion
- func (object *ObjectBase) Init(id string, digest checksum.DigestAlgorithm, fixity []checksum.DigestAlgorithm, ...) error
- func (object *ObjectBase) IsModified() bool
- func (object *ObjectBase) Load() (err error)
- func (object *ObjectBase) LoadInventory(folder string) (Inventory, error)
- func (object *ObjectBase) RenameFile(virtualFilenameSource, virtualFilenameDest string, digest string) error
- func (object *ObjectBase) StartUpdate(sourceFS fs.FS, msg string, UserName string, UserAddress string, echo bool) (fs.FS, error)
- func (object *ObjectBase) Stat(w io.Writer, statInfo []StatInfo) error
- func (object *ObjectBase) StoreExtensions() error
- func (object *ObjectBase) StoreInventory(version bool, objectRoot bool) error
- type ObjectMetadata
- type ObjectV1_0
- type ObjectV1_1
- type ObjectV2_0
- type StatInfo
- type StateFileCallback
- type StorageRoot
- func CreateStorageRoot(ctx context.Context, fsys fs.FS, version OCFLVersion, ...) (StorageRoot, error)
- func LoadStorageRoot(ctx context.Context, fsys fs.FS, extensionFactory *ExtensionFactory, ...) (StorageRoot, error)
- func LoadStorageRootRO(ctx context.Context, fsys fs.FS, extensionFactory *ExtensionFactory, ...) (StorageRoot, error)
- type StorageRootBase
- func (osr *StorageRootBase) Check() error
- func (osr *StorageRootBase) CheckDirectory() (err error)
- func (osr *StorageRootBase) CheckObjectByFolder(objectFolder string) error
- func (osr *StorageRootBase) CheckObjectByID(objectID string) error
- func (osr *StorageRootBase) CheckObjects() error
- func (osr *StorageRootBase) Context() context.Context
- func (osr *StorageRootBase) CreateExtension(fsys fs.FS) (Extension, error)
- func (osr *StorageRootBase) CreateExtensions(fsys fs.FS, validation Validation) (ExtensionManager, error)
- func (osr *StorageRootBase) CreateObject(id string, version OCFLVersion, digest checksum.DigestAlgorithm, ...) (Object, error)
- func (osr *StorageRootBase) Extract(fsys fs.FS, path, id, version string, withManifest bool, area string) error
- func (osr *StorageRootBase) ExtractMeta(path, id string) (*StorageRootMetadata, error)
- func (osr *StorageRootBase) GetDigest() checksum.DigestAlgorithm
- func (osr *StorageRootBase) GetFiles() ([]string, error)
- func (osr *StorageRootBase) GetFolders() ([]string, error)
- func (osr *StorageRootBase) GetObjectFolders() ([]string, error)
- func (osr *StorageRootBase) GetVersion() OCFLVersion
- func (osr *StorageRootBase) Init(version OCFLVersion, digest checksum.DigestAlgorithm, ...) error
- func (osr *StorageRootBase) IsModified() bool
- func (osr *StorageRootBase) Load() error
- func (osr *StorageRootBase) LoadObjectByFolder(folder string) (Object, error)
- func (osr *StorageRootBase) LoadObjectByID(id string) (object Object, err error)
- func (osr *StorageRootBase) ObjectExists(id string) (bool, error)
- func (osr *StorageRootBase) SetDigest(digest checksum.DigestAlgorithm)
- func (osr *StorageRootBase) Stat(w io.Writer, path string, id string, statInfo []StatInfo) error
- func (osr *StorageRootBase) StoreExtensionConfig(name string, config any) error
- func (osr *StorageRootBase) String() string
- type StorageRootMetadata
- type StorageRootV1_0
- type StorageRootV1_1
- type StorageRootV2_0
- type User
- type Validation
- type ValidationError
- type ValidationErrorCode
- type ValidationStatus
- type Version
- type VersionMetadata
Constants ¶
View Source
const ( ExtensionStorageRootPathName = "StorageRootPath" ExtensionObjectContentPathName = "ObjectContentPath" ExtensionObjectExtractPathName = "ObjectExtractPath" ExtensionObjectExternalPathName = "ObjectExternalPath" ExtensionContentChangeName = "ContentChange" ExtensionObjectChangeName = "ObjectChange" ExtensionFixityDigestName = "FixityDigest" ExtensionMetadataName = "Metadata" ExtensionAreaName = "Area" ExtensionStreamName = "Stream" ExtensionNewVersionName = "NewVersion" ExtensionInitialName = "Initial" )
View Source
const ( E000 = ValidationErrorCode("E000") E001 = ValidationErrorCode("E001") E002 = ValidationErrorCode("E002") E003 = ValidationErrorCode("E003") E004 = ValidationErrorCode("E004") E005 = ValidationErrorCode("E005") E006 = ValidationErrorCode("E006") E007 = ValidationErrorCode("E007") E008 = ValidationErrorCode("E008") E009 = ValidationErrorCode("E009") E010 = ValidationErrorCode("E010") E011 = ValidationErrorCode("E011") E012 = ValidationErrorCode("E012") E013 = ValidationErrorCode("E013") E014 = ValidationErrorCode("E014") E015 = ValidationErrorCode("E015") E016 = ValidationErrorCode("E016") E017 = ValidationErrorCode("E017") E018 = ValidationErrorCode("E018") E019 = ValidationErrorCode("E019") E020 = ValidationErrorCode("E020") E021 = ValidationErrorCode("E021") E022 = ValidationErrorCode("E022") E023 = ValidationErrorCode("E023") E024 = ValidationErrorCode("E024") E025 = ValidationErrorCode("E025") E026 = ValidationErrorCode("E026") E027 = ValidationErrorCode("E027") E028 = ValidationErrorCode("E028") E029 = ValidationErrorCode("E029") E030 = ValidationErrorCode("E030") E031 = ValidationErrorCode("E031") E032 = ValidationErrorCode("E032") E033 = ValidationErrorCode("E033") E034 = ValidationErrorCode("E034") E035 = ValidationErrorCode("E035") E036 = ValidationErrorCode("E036") E037 = ValidationErrorCode("E037") E038 = ValidationErrorCode("E038") E039 = ValidationErrorCode("E039") E040 = ValidationErrorCode("E040") E041 = ValidationErrorCode("E041") E042 = ValidationErrorCode("E042") E043 = ValidationErrorCode("E043") E044 = ValidationErrorCode("E044") E045 = ValidationErrorCode("E045") E046 = ValidationErrorCode("E046") E047 = ValidationErrorCode("E047") E048 = ValidationErrorCode("E048") E049 = ValidationErrorCode("E049") E050 = ValidationErrorCode("E050") E051 = ValidationErrorCode("E051") E052 = ValidationErrorCode("E052") E053 = ValidationErrorCode("E053") E054 = ValidationErrorCode("E054") E055 = ValidationErrorCode("E055") E056 = ValidationErrorCode("E056") E057 = ValidationErrorCode("E057") E058 = ValidationErrorCode("E058") E059 = ValidationErrorCode("E059") E060 = ValidationErrorCode("E060") E061 = ValidationErrorCode("E061") E062 = ValidationErrorCode("E062") E063 = ValidationErrorCode("E063") E064 = ValidationErrorCode("E064") E066 = ValidationErrorCode("E066") E067 = ValidationErrorCode("E067") E068 = ValidationErrorCode("E068") E069 = ValidationErrorCode("E069") E070 = ValidationErrorCode("E070") E071 = ValidationErrorCode("E071") E072 = ValidationErrorCode("E072") E073 = ValidationErrorCode("E073") E074 = ValidationErrorCode("E074") E075 = ValidationErrorCode("E075") E076 = ValidationErrorCode("E076") E077 = ValidationErrorCode("E077") E078 = ValidationErrorCode("E078") E079 = ValidationErrorCode("E079") E080 = ValidationErrorCode("E080") E081 = ValidationErrorCode("E081") E082 = ValidationErrorCode("E082") E083 = ValidationErrorCode("E083") E084 = ValidationErrorCode("E084") E085 = ValidationErrorCode("E085") E086 = ValidationErrorCode("E086") E087 = ValidationErrorCode("E087") E088 = ValidationErrorCode("E088") E089 = ValidationErrorCode("E089") E090 = ValidationErrorCode("E090") E091 = ValidationErrorCode("E091") E092 = ValidationErrorCode("E092") E093 = ValidationErrorCode("E093") E094 = ValidationErrorCode("E094") E095 = ValidationErrorCode("E095") E096 = ValidationErrorCode("E096") E097 = ValidationErrorCode("E097") E098 = ValidationErrorCode("E098") E099 = ValidationErrorCode("E099") E100 = ValidationErrorCode("E100") E101 = ValidationErrorCode("E101") E102 = ValidationErrorCode("E102") E103 = ValidationErrorCode("E103") E104 = ValidationErrorCode("E104") E105 = ValidationErrorCode("E105") E106 = ValidationErrorCode("E106") E107 = ValidationErrorCode("E107") E108 = ValidationErrorCode("E108") E110 = ValidationErrorCode("E110") E111 = ValidationErrorCode("E111") E112 = ValidationErrorCode("E112") W000 = ValidationErrorCode("W000") W001 = ValidationErrorCode("W001") W002 = ValidationErrorCode("W002") W003 = ValidationErrorCode("W003") W004 = ValidationErrorCode("W004") W005 = ValidationErrorCode("W005") W007 = ValidationErrorCode("W007") W008 = ValidationErrorCode("W008") W009 = ValidationErrorCode("W009") W010 = ValidationErrorCode("W010") W011 = ValidationErrorCode("W011") W012 = ValidationErrorCode("W012") W013 = ValidationErrorCode("W013") W014 = ValidationErrorCode("W014") W015 = ValidationErrorCode("W015") W016 = ValidationErrorCode("W016") )
View Source
const (
ContentDirectory1_0 = "content"
)
View Source
const (
ContentDirectory1_1 = "content"
)
View Source
const DefaultExtensionInitialName = "initial"
View Source
const DefaultExtensionManagerName = "NNNN-gocfl-extension-manager"
View Source
const ObjectV11Version = "1.1"
View Source
const ObjectV20Version = "2.0"
Variables ¶
View Source
var ErrFilenameTooLong = errors.New("filename too long")
View Source
var ErrPathnameTooLong = errors.New("pathname too long")
View Source
var ExtensionObjectExtractPathWrongAreaError = fmt.Errorf("invalid area")
View Source
var OCFLValidationError1_0 = map[ValidationErrorCode]*ValidationError{}/* 116 elements not displayed */
View Source
var OCFLValidationError1_1 = map[ValidationErrorCode]*ValidationError{}/* 125 elements not displayed */
View Source
var OCFLValidationErrorMapping1_0 = map[ValidationErrorCode]ValidationErrorCode{ E104: E001, }
View Source
var OCFLValidationErrorMapping1_1 = map[ValidationErrorCode]ValidationErrorCode{}
View Source
var OCFLVersionRegexp = regexp.MustCompile("^0=ocfl_([0-9]+\\.[0-9]+)$")
View Source
var StatInfoString = map[string]StatInfo{ "ObjectFolders": StatObjectFolders, "Extension": StatExtension, "ExtensionConfigs": StatExtensionConfigs, "Objects": StatObjects, "ObjectVersions": StatObjectVersions, "ObjectVersionState": StatObjectVersionState, "ObjectManifest": StatObjectManifest, "ObjectExtension": StatObjectExtension, "ObjectExtensionConfigs": StatObjectExtensionConfigs, }
Functions ¶
func FixFilename ¶
FixFilename *********************************************************************
- 1) Forbid/escape ASCII control characters (bytes 1-31 and 127) in filenames, including newline, escape, and tab.
- I know of no user or program that actually requires this capability. As far as I can tell, this capability
- exists only to make it hard to write correct software, to ease the job of attackers, and to create
- interoperability problems. Chuck it.
- 2) Forbid/escape leading “-”. This way, you can always distinguish option flags from filenames, eliminating a host
- of stupid emperror. Nobody in their right mind writes programs that depend on having dash-prefixed files on a Unix
- system. Even on Windows systems they’re a bad idea, because many programs use “-” instead of “/” to identify options.
- 3) Forbid/escape filenames that aren’t a valid UTF-8 encoding. This way, filenames can always be correctly displayed.
- Trying to use environment values like LC_ALL (or other LC_* values) or LANG is just a hack that often fails. This
- will take time, as people slowly transition and minor tool problems get fixed, but I believe that transition is
- already well underway.
- 4) Forbid/escape leading/trailing space characters — at least trailing spaces. Adjacent spaces are somewhat dodgy,
- too. These confuse users when they happen, with no utility. In particular, filenames that are only space characters
- are nothing but trouble. Some systems may want to go further and forbid space characters outright, but I doubt that’ll
- be acceptable everywhere, and with the other approaches these are less necessary. As noted above, an interesting
- alternative would be quietly convert (in the API) all spaces into unbreakable spaces.
- 5) Forbid/escape “problematic” characters that get specially interpreted by shells, other interpreters (such as perl),
- and HTML/XML. This is less important, and I would expect this to happen (at most) on specific systems. With the steps
- above, a lot of programs and statements like “cat *” just work correctly. But funny characters cause troubles for shell
- scripts and perl, because they need to quote them when typing in commands.. and they often forget to do so. They can
- also be a cause for trouble when they’re passed down to other programs, especially if they run “exec” and so on. They’re
- also helpful for web applications, again, because the characters that should be escapes are sometimes not escaped. A short
- list would be “*”, “?”, and “[”; by eliminating those three characters and control characters from filenames, and removing
- the space character from IFS, you can process filenames in shells without quoting variable references — eliminating a
- common source of emperror. Forbidding/escaping “<” and “>” would eliminate a source of nasty errors for perl programs, web
- applications, and anyone using HTML or XML. A more stringent list would be “*?:[]"<>|(){}&'!\;” (this is Glindra’s “safe”
- list with ampersand, single-quote, bang, backslash, and semicolon added). This list is probably a little extreme, but let’s
- try and see. As noted earlier, I’d need to go through a complete analysis of all characters for a final list; for security,
- you want to identify everything that is permissible, and disallow everything else, but its manifestation can be either way
- as long as you’ve considered all possible cases. But if this set can be determined locally, based on local requirements,
- there’s less need to get complete agreement on a list.
- 6) Forbid/escape leading “~” (tilde). Shells specially interpret such filenames. This is definitely low priority. *
- https://www.dwheeler.com/essays/fixing-unix-linux-filenames.html
func GetErrorStacktrace ¶
func GetErrorStacktrace(err error) errors.StackTrace
func InventoryIsEqual ¶
func SpecIsLessOrEqual ¶
func SpecIsLessOrEqual(s1, s2 InventorySpec) bool
return true if Specification s1 < s2
func ValidVersion ¶
func ValidVersion(version OCFLVersion) bool
Types ¶
type Extension ¶
type ExtensionArea ¶
type ExtensionConfig ¶
type ExtensionConfig struct {
ExtensionName string `json:"extensionName"`
}
type ExtensionContentChange ¶
type ExtensionContentChange interface { Extension AddFileBefore(object Object, sourceFS fs.FS, source string, dest string, area string, isDir bool) error UpdateFileBefore(object Object, sourceFS fs.FS, source, dest, area string, isDir bool) error DeleteFileBefore(object Object, dest string, area string) error AddFileAfter(object Object, sourceFS fs.FS, source []string, internalPath, digest, area string, isDir bool) error UpdateFileAfter(object Object, sourceFS fs.FS, source, dest, area string, isDir bool) error DeleteFileAfter(object Object, dest string, area string) error }
type ExtensionExternalParam ¶
type ExtensionExternalParam struct { ExtensionName string Functions []string Param string // File string Description string Default string }
func (*ExtensionExternalParam) GetCobraName ¶
func (eep *ExtensionExternalParam) GetCobraName() string
func (*ExtensionExternalParam) GetParam ¶
func (eep *ExtensionExternalParam) GetParam(cmd *cobra.Command, conf *config.GOCFLConfig) (name, value string)
func (*ExtensionExternalParam) SetParam ¶
func (eep *ExtensionExternalParam) SetParam(cmd *cobra.Command)
type ExtensionFactory ¶
type ExtensionFactory struct {
// contains filtered or unexported fields
}
func NewExtensionFactory ¶
func (*ExtensionFactory) AddCreator ¶
func (f *ExtensionFactory) AddCreator(name string, creator creatorFunc)
func (*ExtensionFactory) AddObjectDefaultExtension ¶
func (f *ExtensionFactory) AddObjectDefaultExtension(ext Extension)
func (*ExtensionFactory) AddStorageRootDefaultExtension ¶
func (f *ExtensionFactory) AddStorageRootDefaultExtension(ext Extension)
func (*ExtensionFactory) CreateExtensions ¶
func (f *ExtensionFactory) CreateExtensions(fsys fs.FS, validation Validation) (ExtensionManager, error)
func (*ExtensionFactory) LoadExtensions ¶
func (f *ExtensionFactory) LoadExtensions(fsys fs.FS, validation Validation) (ExtensionManager, error)
type ExtensionFixityDigest ¶
type ExtensionFixityDigest interface { Extension GetFixityDigests() []checksum.DigestAlgorithm }
type ExtensionInitial ¶
type ExtensionManager ¶
type ExtensionManager interface { Extension ExtensionStorageRootPath ExtensionObjectContentPath ExtensionObjectStatePath ExtensionContentChange ExtensionObjectChange ExtensionFixityDigest ExtensionObjectExtractPath ExtensionMetadata ExtensionArea ExtensionStream ExtensionNewVersion GetConfig() any GetExtensions() []Extension Add(ext Extension) error Finalize() GetConfigName(extName string) (any, error) GetFSName(extName string) (fs.FS, error) StoreRootLayout(fsys fs.FS) error SetInitial(initial ExtensionInitial) }
type ExtensionManagerConfig ¶
type ExtensionManagerConfig struct { *ExtensionConfig Sort map[string][]string `json:"sort"` Exclusion map[string][][]string `json:"exclusion"` }
type ExtensionMetadata ¶
type ExtensionNewVersion ¶
type ExtensionObjectChange ¶
type ExtensionStream ¶
type FileMetadata ¶
type InitialDummy ¶
type InitialDummy struct {
*ExtensionManagerConfig
}
func NewInitialDummy ¶
func NewInitialDummy(config *ExtensionManagerConfig) (*InitialDummy, error)
func (*InitialDummy) GetConfig ¶
func (dummy *InitialDummy) GetConfig() any
func (*InitialDummy) GetConfigString ¶
func (dummy *InitialDummy) GetConfigString() string
func (*InitialDummy) GetFS ¶
func (dummy *InitialDummy) GetFS() fs.FS
func (*InitialDummy) GetName ¶
func (dummy *InitialDummy) GetName() string
func (*InitialDummy) IsRegistered ¶
func (dummy *InitialDummy) IsRegistered() bool
func (*InitialDummy) SetParams ¶
func (dummy *InitialDummy) SetParams(params map[string]string) error
func (*InitialDummy) Terminate ¶
func (dummy *InitialDummy) Terminate() error
func (*InitialDummy) WriteConfig ¶
func (dummy *InitialDummy) WriteConfig() error
type Inventory ¶
type Inventory interface { Finalize(inCreation bool) error IsEqual(i2 Inventory) bool Init(id string, digest checksum.DigestAlgorithm, fixity []checksum.DigestAlgorithm) error GetID() string GetContentDir() string GetRealContentDir() string GetHead() string GetSpec() InventorySpec CheckFiles(fileManifest map[checksum.DigestAlgorithm]map[string][]string) error DeleteFile(stateFilename string) error RenameFile(stateSource, stateDest string) error //Rename(oldVirtualFilename, newVirtualFilename string) error AddFile(stateFilenames []string, manifestFilename string, checksums map[checksum.DigestAlgorithm]string) error CopyFile(dest string, digest string) error IterateStateFiles(version string, fn StateFileCallback) error GetStateFiles(version string, cs string) ([]string, error) //GetContentDirectory() string GetVersionStrings() []string GetVersions() map[string]*Version GetFiles() map[string][]string GetManifest() map[string][]string GetFixity() Fixity GetFilesFlat() []string GetDigestAlgorithm() checksum.DigestAlgorithm GetFixityDigestAlgorithm() []checksum.DigestAlgorithm IsWriteable() bool IsModified() bool BuildManifestName(stateFilename string) string BuildManifestNameVersion(stateFilename string, version string) string NewVersion(msg, UserName, UserAddress string) error GetDuplicates(checksum string) []string AlreadyExists(stateFilename, checksum string) (bool, error) // IsUpdate(virtualFilename, checksum string) (bool, error) Clean() error VersionLessOrEqual(v1, v2 string) bool // contains filtered or unexported methods }
type InventoryBase ¶
type InventoryBase struct { Id string `json:"id"` Type InventorySpec `json:"type"` DigestAlgorithm checksum.DigestAlgorithm `json:"digestAlgorithm"` Head *OCFLString `json:"head"` ContentDirectory string `json:"contentDirectory,omitempty"` Manifest *OCFLManifest `json:"manifest,omitempty"` Versions *OCFLVersions `json:"versions"` Fixity map[checksum.DigestAlgorithm]map[string][]string `json:"fixity,omitempty"` // contains filtered or unexported fields }
func (*InventoryBase) AddFile ¶
func (i *InventoryBase) AddFile(stateFilenames []string, manifestFilename string, checksums map[checksum.DigestAlgorithm]string) error
func (*InventoryBase) AlreadyExists ¶
func (i *InventoryBase) AlreadyExists(stateFilename, checksum string) (bool, error)
func (*InventoryBase) BuildManifestName ¶
func (i *InventoryBase) BuildManifestName(stateFilename string) string
func (*InventoryBase) BuildManifestNameVersion ¶
func (i *InventoryBase) BuildManifestNameVersion(stateFilename string, version string) string
func (*InventoryBase) CheckFiles ¶
func (i *InventoryBase) CheckFiles(fileManifest map[checksum.DigestAlgorithm]map[string][]string) error
func (*InventoryBase) DeleteFile ¶
func (i *InventoryBase) DeleteFile(stateFilename string) error
func (*InventoryBase) Finalize ¶
func (i *InventoryBase) Finalize(inCreation bool) (err error)
func (*InventoryBase) GetContentDir ¶
func (i *InventoryBase) GetContentDir() string
func (*InventoryBase) GetDigestAlgorithm ¶
func (i *InventoryBase) GetDigestAlgorithm() checksum.DigestAlgorithm
func (*InventoryBase) GetDuplicates ¶
func (i *InventoryBase) GetDuplicates(checksum string) []string
func (*InventoryBase) GetFiles ¶
func (i *InventoryBase) GetFiles() map[string][]string
func (*InventoryBase) GetFilesFlat ¶
func (i *InventoryBase) GetFilesFlat() []string
func (*InventoryBase) GetFixity ¶
func (i *InventoryBase) GetFixity() Fixity
func (*InventoryBase) GetFixityDigestAlgorithm ¶
func (i *InventoryBase) GetFixityDigestAlgorithm() []checksum.DigestAlgorithm
func (*InventoryBase) GetHead ¶
func (i *InventoryBase) GetHead() string
func (*InventoryBase) GetID ¶
func (i *InventoryBase) GetID() string
func (*InventoryBase) GetManifest ¶
func (i *InventoryBase) GetManifest() map[string][]string
func (*InventoryBase) GetRealContentDir ¶
func (i *InventoryBase) GetRealContentDir() string
func (*InventoryBase) GetSpec ¶
func (i *InventoryBase) GetSpec() InventorySpec
func (*InventoryBase) GetStateFiles ¶
func (i *InventoryBase) GetStateFiles(version string, cs string) ([]string, error)
func (*InventoryBase) GetVersionStrings ¶
func (i *InventoryBase) GetVersionStrings() []string
func (*InventoryBase) GetVersions ¶
func (i *InventoryBase) GetVersions() map[string]*Version
func (*InventoryBase) Init ¶
func (i *InventoryBase) Init(id string, digest checksum.DigestAlgorithm, fixity []checksum.DigestAlgorithm) (err error)
func (*InventoryBase) IsModified ¶
func (i *InventoryBase) IsModified() bool
func (*InventoryBase) IsUpdate ¶
func (i *InventoryBase) IsUpdate(virtualFilename, checksum string) (bool, error)
func (*InventoryBase) IsWriteable ¶
func (i *InventoryBase) IsWriteable() bool
func (*InventoryBase) IterateStateFiles ¶
func (i *InventoryBase) IterateStateFiles(version string, fn StateFileCallback) error
func (*InventoryBase) NewVersion ¶
func (i *InventoryBase) NewVersion(msg, UserName, UserAddress string) error
func (*InventoryBase) RenameFile ¶
func (i *InventoryBase) RenameFile(stateSource, stateDest string) error
func (*InventoryBase) VersionLessOrEqual ¶
func (i *InventoryBase) VersionLessOrEqual(v1, v2 string) bool
type InventorySpec ¶
type InventorySpec string
const ( InventorySpec1_0 InventorySpec = "https://ocfl.io/1.0/spec/#inventory" InventorySpec1_1 InventorySpec = "https://ocfl.io/1.1/spec/#inventory" )
type InventoryV1_0 ¶
type InventoryV1_0 struct {
*InventoryBase
}
func (*InventoryV1_0) IsEqual ¶
func (i *InventoryV1_0) IsEqual(i2 Inventory) bool
type InventoryV1_1 ¶
type InventoryV1_1 struct {
*InventoryBase
}
func (*InventoryV1_1) IsEqual ¶
func (i *InventoryV1_1) IsEqual(i2 Inventory) bool
type NamesStruct ¶
type OCFLManifest ¶
func (*OCFLManifest) MarshalJSON ¶
func (m *OCFLManifest) MarshalJSON() ([]byte, error)
func (*OCFLManifest) UnmarshalJSON ¶
func (m *OCFLManifest) UnmarshalJSON(data []byte) error
type OCFLString ¶
type OCFLString struct {
// contains filtered or unexported fields
}
func NewOCFLString ¶
func NewOCFLString(str string) *OCFLString
func (*OCFLString) MarshalJSON ¶
func (s *OCFLString) MarshalJSON() ([]byte, error)
func (*OCFLString) String ¶
func (s *OCFLString) String() string
func (*OCFLString) UnmarshalJSON ¶
func (s *OCFLString) UnmarshalJSON(data []byte) error
type OCFLUser ¶
type OCFLUser struct { User // contains filtered or unexported fields }
func NewOCFLUser ¶
func (*OCFLUser) UnmarshalJSON ¶
type OCFLVersion ¶
type OCFLVersion string
const Version1_0 OCFLVersion = "1.0"
const Version1_1 OCFLVersion = "1.1"
const Version2_0 OCFLVersion = "2.0"
func GetObjectVersion ¶
type OCFLVersions ¶
func (*OCFLVersions) GetVersion ¶
func (v *OCFLVersions) GetVersion(version string) (*Version, error)
func (*OCFLVersions) MarshalJSON ¶
func (v *OCFLVersions) MarshalJSON() ([]byte, error)
func (*OCFLVersions) UnmarshalJSON ¶
func (v *OCFLVersions) UnmarshalJSON(data []byte) error
type Object ¶
type Object interface { LoadInventory(folder string) (Inventory, error) CreateInventory(id string, digest checksum.DigestAlgorithm, fixity []checksum.DigestAlgorithm) (Inventory, error) StoreInventory(version bool, objectRoot bool) error GetInventory() Inventory StoreExtensions() error Init(id string, digest checksum.DigestAlgorithm, fixity []checksum.DigestAlgorithm, manager ExtensionManager) error Load() error StartUpdate(sourceFS fs.FS, msg string, UserName string, UserAddress string, echo bool) (fs.FS, error) EndUpdate() error BeginArea(area string) EndArea() error AddFolder(fsys fs.FS, versionFS fs.FS, checkDuplicate bool, area string) error AddFile(fsys fs.FS, versionFS fs.FS, path string, checkDuplicate bool, area string, noExtensionHook bool, isDir bool) error AddData(data []byte, path string, checkDuplicate bool, area string, noExtensionHook bool, isDir bool) error AddReader(r io.ReadCloser, files []string, area string, noExtensionHook bool, isDir bool) (string, error) DeleteFile(virtualFilename string, digest string) error RenameFile(virtualFilenameSource, virtualFilenameDest string, digest string) error GetID() string GetVersion() OCFLVersion Check() error Close() error GetFS() fs.FS IsModified() bool Stat(w io.Writer, statInfo []StatInfo) error Extract(fsys fs.FS, version string, withManifest bool, area string) error GetMetadata() (*ObjectMetadata, error) GetAreaPath(area string) (string, error) GetExtensionManager() ExtensionManager BuildNames(files []string, area string) (*NamesStruct, error) }
type ObjectBase ¶
type ObjectBase struct {
// contains filtered or unexported fields
}
func (*ObjectBase) AddReader ¶
func (object *ObjectBase) AddReader(r io.ReadCloser, files []string, area string, noExtensionHook bool, isDir bool) (string, error)
func (*ObjectBase) BeginArea ¶
func (object *ObjectBase) BeginArea(area string)
func (*ObjectBase) BuildNames ¶
func (object *ObjectBase) BuildNames(files []string, area string) (*NamesStruct, error)
func (*ObjectBase) Check ¶
func (object *ObjectBase) Check() error
func (*ObjectBase) Close ¶
func (object *ObjectBase) Close() error
func (*ObjectBase) CreateInventory ¶
func (object *ObjectBase) CreateInventory(id string, digest checksum.DigestAlgorithm, fixity []checksum.DigestAlgorithm) (Inventory, error)
func (*ObjectBase) DeleteFile ¶
func (object *ObjectBase) DeleteFile(virtualFilename string, digest string) error
func (*ObjectBase) EndArea ¶
func (object *ObjectBase) EndArea() error
func (*ObjectBase) EndUpdate ¶
func (object *ObjectBase) EndUpdate() error
func (*ObjectBase) GetAreaPath ¶
func (object *ObjectBase) GetAreaPath(area string) (string, error)
func (*ObjectBase) GetDigestAlgorithm ¶
func (object *ObjectBase) GetDigestAlgorithm() checksum.DigestAlgorithm
func (*ObjectBase) GetExtensionManager ¶
func (object *ObjectBase) GetExtensionManager() ExtensionManager
func (*ObjectBase) GetFS ¶
func (object *ObjectBase) GetFS() fs.FS
func (*ObjectBase) GetID ¶
func (object *ObjectBase) GetID() string
func (*ObjectBase) GetInventory ¶
func (object *ObjectBase) GetInventory() Inventory
func (*ObjectBase) GetMetadata ¶
func (object *ObjectBase) GetMetadata() (*ObjectMetadata, error)
func (*ObjectBase) GetVersion ¶
func (object *ObjectBase) GetVersion() OCFLVersion
func (*ObjectBase) Init ¶
func (object *ObjectBase) Init(id string, digest checksum.DigestAlgorithm, fixity []checksum.DigestAlgorithm, extensionManager ExtensionManager) error
func (*ObjectBase) IsModified ¶
func (object *ObjectBase) IsModified() bool
func (*ObjectBase) Load ¶
func (object *ObjectBase) Load() (err error)
func (*ObjectBase) LoadInventory ¶
func (object *ObjectBase) LoadInventory(folder string) (Inventory, error)
loadInventory loads inventory from existing Object
func (*ObjectBase) RenameFile ¶
func (object *ObjectBase) RenameFile(virtualFilenameSource, virtualFilenameDest string, digest string) error
func (*ObjectBase) StartUpdate ¶
func (*ObjectBase) StoreExtensions ¶
func (object *ObjectBase) StoreExtensions() error
func (*ObjectBase) StoreInventory ¶
func (object *ObjectBase) StoreInventory(version bool, objectRoot bool) error
type ObjectMetadata ¶
type ObjectMetadata struct { ID string DigestAlgorithm checksum.DigestAlgorithm Head string Versions map[string]*VersionMetadata Files map[string]*FileMetadata Extension any }
type ObjectV1_0 ¶
type ObjectV1_0 struct {
*ObjectBase
}
type ObjectV1_1 ¶
type ObjectV1_1 struct {
*ObjectBase
}
type ObjectV2_0 ¶
type ObjectV2_0 struct {
*ObjectBase
}
type StateFileCallback ¶
type StorageRoot ¶
type StorageRoot interface { fmt.Stringer GetDigest() checksum.DigestAlgorithm SetDigest(digest checksum.DigestAlgorithm) GetFiles() ([]string, error) GetFolders() ([]string, error) GetObjectFolders() ([]string, error) ObjectExists(id string) (bool, error) LoadObjectByFolder(folder string) (Object, error) LoadObjectByID(id string) (Object, error) CreateObject(id string, version OCFLVersion, digest checksum.DigestAlgorithm, fixity []checksum.DigestAlgorithm, manager ExtensionManager) (Object, error) CreateExtension(fsys fs.FS) (Extension, error) CreateExtensions(fsys fs.FS, validation Validation) (ExtensionManager, error) Check() error CheckObjectByFolder(objectFolder string) error CheckObjectByID(objectID string) error Init(version OCFLVersion, digest checksum.DigestAlgorithm, manager ExtensionManager) error Load() error IsModified() bool GetVersion() OCFLVersion Stat(w io.Writer, path string, id string, statInfo []StatInfo) error Extract(fsys fs.FS, path, id, version string, withManifest bool, area string) error ExtractMeta(path, id string) (*StorageRootMetadata, error) // contains filtered or unexported methods }
func CreateStorageRoot ¶
func CreateStorageRoot(ctx context.Context, fsys fs.FS, version OCFLVersion, extensionFactory *ExtensionFactory, extensionManager ExtensionManager, digest checksum.DigestAlgorithm, logger zLogger.ZLogger) (StorageRoot, error)
func LoadStorageRoot ¶
func LoadStorageRoot(ctx context.Context, fsys fs.FS, extensionFactory *ExtensionFactory, logger zLogger.ZLogger) (StorageRoot, error)
func LoadStorageRootRO ¶
func LoadStorageRootRO(ctx context.Context, fsys fs.FS, extensionFactory *ExtensionFactory, logger zLogger.ZLogger) (StorageRoot, error)
type StorageRootBase ¶
type StorageRootBase struct {
// contains filtered or unexported fields
}
func NewStorageRootBase ¶
func NewStorageRootBase(ctx context.Context, fsys fs.FS, defaultVersion OCFLVersion, extensionFactory *ExtensionFactory, extensionManager ExtensionManager, logger zLogger.ZLogger) (*StorageRootBase, error)
NewOCFL creates an empty OCFL structure
func (*StorageRootBase) Check ¶
func (osr *StorageRootBase) Check() error
func (*StorageRootBase) CheckDirectory ¶
func (osr *StorageRootBase) CheckDirectory() (err error)
func (*StorageRootBase) CheckObjectByFolder ¶
func (osr *StorageRootBase) CheckObjectByFolder(objectFolder string) error
func (*StorageRootBase) CheckObjectByID ¶
func (osr *StorageRootBase) CheckObjectByID(objectID string) error
func (*StorageRootBase) CheckObjects ¶
func (osr *StorageRootBase) CheckObjects() error
func (*StorageRootBase) Context ¶
func (osr *StorageRootBase) Context() context.Context
func (*StorageRootBase) CreateExtension ¶
func (osr *StorageRootBase) CreateExtension(fsys fs.FS) (Extension, error)
func (*StorageRootBase) CreateExtensions ¶
func (osr *StorageRootBase) CreateExtensions(fsys fs.FS, validation Validation) (ExtensionManager, error)
func (*StorageRootBase) CreateObject ¶
func (osr *StorageRootBase) CreateObject(id string, version OCFLVersion, digest checksum.DigestAlgorithm, fixity []checksum.DigestAlgorithm, manager ExtensionManager) (Object, error)
func (*StorageRootBase) ExtractMeta ¶
func (osr *StorageRootBase) ExtractMeta(path, id string) (*StorageRootMetadata, error)
func (*StorageRootBase) GetDigest ¶
func (osr *StorageRootBase) GetDigest() checksum.DigestAlgorithm
func (*StorageRootBase) GetFiles ¶
func (osr *StorageRootBase) GetFiles() ([]string, error)
func (*StorageRootBase) GetFolders ¶
func (osr *StorageRootBase) GetFolders() ([]string, error)
func (*StorageRootBase) GetObjectFolders ¶
func (osr *StorageRootBase) GetObjectFolders() ([]string, error)
all folder trees, which end in a folder containing a file
func (*StorageRootBase) GetVersion ¶
func (osr *StorageRootBase) GetVersion() OCFLVersion
func (*StorageRootBase) Init ¶
func (osr *StorageRootBase) Init(version OCFLVersion, digest checksum.DigestAlgorithm, extensionManager ExtensionManager) error
func (*StorageRootBase) IsModified ¶
func (osr *StorageRootBase) IsModified() bool
func (*StorageRootBase) Load ¶
func (osr *StorageRootBase) Load() error
func (*StorageRootBase) LoadObjectByFolder ¶
func (osr *StorageRootBase) LoadObjectByFolder(folder string) (Object, error)
func (*StorageRootBase) LoadObjectByID ¶
func (osr *StorageRootBase) LoadObjectByID(id string) (object Object, err error)
func (*StorageRootBase) ObjectExists ¶
func (osr *StorageRootBase) ObjectExists(id string) (bool, error)
func (*StorageRootBase) SetDigest ¶
func (osr *StorageRootBase) SetDigest(digest checksum.DigestAlgorithm)
func (*StorageRootBase) StoreExtensionConfig ¶
func (osr *StorageRootBase) StoreExtensionConfig(name string, config any) error
func (*StorageRootBase) String ¶
func (osr *StorageRootBase) String() string
type StorageRootMetadata ¶
type StorageRootMetadata struct {
Objects map[string]*ObjectMetadata
}
type StorageRootV1_0 ¶
type StorageRootV1_0 struct {
*StorageRootBase
}
func NewStorageRootV1_0 ¶
func NewStorageRootV1_0(ctx context.Context, fsys fs.FS, extensionFactory *ExtensionFactory, manager ExtensionManager, logger zLogger.ZLogger) (*StorageRootV1_0, error)
type StorageRootV1_1 ¶
type StorageRootV1_1 struct {
*StorageRootBase
}
func NewStorageRootV1_1 ¶
func NewStorageRootV1_1(ctx context.Context, fsys fs.FS, extensionFactory *ExtensionFactory, extensionManager ExtensionManager, logger zLogger.ZLogger) (*StorageRootV1_1, error)
func (*StorageRootV1_1) Init ¶
func (osr *StorageRootV1_1) Init(version OCFLVersion, digest checksum.DigestAlgorithm, manager ExtensionManager) error
type StorageRootV2_0 ¶
type StorageRootV2_0 struct {
*StorageRootBase
}
func NewStorageRootV2_0 ¶
func NewStorageRootV2_0(ctx context.Context, fsys fs.FS, extensionFactory *ExtensionFactory, extensionManager ExtensionManager, logger zLogger.ZLogger) (*StorageRootV2_0, error)
func (*StorageRootV2_0) Init ¶
func (osr *StorageRootV2_0) Init(version OCFLVersion, digest checksum.DigestAlgorithm, manager ExtensionManager) error
type User ¶
type User struct { Address *OCFLString `json:"address,omitempty"` Name *OCFLString `json:"name"` }
type Validation ¶
type Validation interface {
// contains filtered or unexported methods
}
type ValidationError ¶
type ValidationError struct { Code ValidationErrorCode Description string Ref string Description2 string Context string Version OCFLVersion }
func GetValidationError ¶
func GetValidationError(version OCFLVersion, errno ValidationErrorCode) *ValidationError
func (*ValidationError) AppendContext ¶
func (ve *ValidationError) AppendContext(format string, a ...any) *ValidationError
func (*ValidationError) AppendDescription ¶
func (ve *ValidationError) AppendDescription(format string, a ...any) *ValidationError
func (*ValidationError) DetailString ¶
func (ve *ValidationError) DetailString() string
func (*ValidationError) Error ¶
func (verr *ValidationError) Error() string
type ValidationErrorCode ¶
type ValidationErrorCode string
type ValidationStatus ¶
type ValidationStatus struct {
Errors []*ValidationError
}
func GetValidationStatus ¶
func GetValidationStatus(ctx context.Context) (*ValidationStatus, error)
func (*ValidationStatus) Compact ¶
func (status *ValidationStatus) Compact()
removes duplicate errors
type Version ¶
type Version struct { Created *OCFLTime `json:"created"` Message *OCFLString `json:"message"` State *OCFLState `json:"state"` User *OCFLUser `json:"user"` }
func (*Version) EqualState ¶
Source Files
¶
- extension.go
- extensionExternalParam.go
- extensionFactory.go
- extensionInitialDummy.go
- extensionManager.go
- fixity.go
- fs.go
- helper.go
- inventory.go
- inventory1_0.go
- inventory1_1.go
- inventorybase.go
- inventorytypes.go
- metadata.go
- object.go
- object1_0.go
- object1_1.go
- object2_0.go
- objectbase.go
- stat.go
- storageroot.go
- storageroot1_0.go
- storageroot1_1.go
- storageroot2_0.go
- storagerootbase.go
- validation.go
- validationerror.go
- validationerror1_0.go
- validationerror1_1.go
Click to show internal directories.
Click to hide internal directories.