BagItTools

TagManifest extends AbstractManifest
in package

Tag Manifest extension of AbstractManifest class.

Tags
author

whikloj

since
1.0.0

Table of Contents

$algorithm  : string
The hash algorithm for this manifest.
$bag  : Bag
The bag this manifest is part of.
$filename  : string
The filename for this manifest.
$hashes  : array<string|int, mixed>
Associative array where paths are keys and hashes are values.
$loadIssues  : array<string|int, mixed>
Errors/Warnings generated while loading.
$manifestErrors  : array<string|int, mixed>
Errors while validating this manifest.
$manifestWarnings  : array<string|int, mixed>
Warnings generated while validating this manifest.
$normalizedPaths  : array<string|int, mixed>
Array of the same paths as in $hashes but normalized for case and characters to check for duplication.
__construct()  : mixed
PayloadManifest constructor.
getAlgorithm()  : string
Return the algorithm for this manifest.
getErrors()  : array<string|int, mixed>
Return the array of errors.
getFilename()  : string
Return the filename of this manifest.
getHashes()  : array<string|int, mixed>
Return the payload and hashes as an associative array.
getWarnings()  : array<string|int, mixed>
Return the array of warnings.
update()  : void
Update the hashes for each path.
validate()  : void
Compare file hashes against what is on disk.
addError()  : void
Add an error using the current filename.
addWarning()  : void
Add a warning using the current filename.
calculateHash()  : string
Calculate the hash of the file.
getPhpHashName()  : string
Needed to account for differences in PHP hash to BagIt hash naming.
loadFile()  : void
Load the paths and hashes from the file on disk, does not validate.
writeToDisk()  : void
Utility to recreate the manifest file using the currently stored hashes.
addLoadError()  : void
Add a load error using the current filename. This is only erased on a new load.
addLoadWarning()  : void
Add a load warning using the current filename. This is only erased on a new load.
addToNormalizedList()  : void
Add a path to the list of normalized paths.
checkIncomingFilePath()  : void
Does validation on incoming file paths.
cleanUpRelPath()  : string
Clean up file paths to remove extraneous periods, double periods and slashes
isTagManifest()  : bool
Is the filename match a tag manifest file?
matchNormalizedList()  : bool
Compare a path against a list of normalized paths and look for matches.
normalizePath()  : string
Normalize a path for character representation and case.
resetLoadIssues()  : void
Utility to reset the load issues construct.

Properties

$algorithm

The hash algorithm for this manifest.

protected string $algorithm

$hashes

Associative array where paths are keys and hashes are values.

protected array<string|int, mixed> $hashes = []

$loadIssues

Errors/Warnings generated while loading.

protected array<string|int, mixed> $loadIssues

Because of the path key in the hash array if there are multiple entries for a path we need to track it during load but present it at validate().

Array of arrays with keys 'error' and 'warning'

Tags
see
AbstractManifest::resetLoadIssues()

$manifestErrors

Errors while validating this manifest.

protected array<string|int, mixed> $manifestErrors = []

$manifestWarnings

Warnings generated while validating this manifest.

protected array<string|int, mixed> $manifestWarnings = []

$normalizedPaths

Array of the same paths as in $hashes but normalized for case and characters to check for duplication.

protected array<string|int, mixed> $normalizedPaths = []

Methods

__construct()

PayloadManifest constructor.

public __construct(Bag $bag, string $algorithm[, bool $load = false ]) : mixed
Parameters
$bag : Bag

The bag this manifest is part of.

$algorithm : string

The BagIt name of the hash algorithm.

$load : bool = false

Whether we are loading an existing file

Tags
throws
FilesystemException

Unable to read manifest file.

Return values
mixed

getAlgorithm()

Return the algorithm for this manifest.

public getAlgorithm() : string
Return values
string

getErrors()

Return the array of errors.

public getErrors() : array<string|int, mixed>
Return values
array<string|int, mixed>

getFilename()

Return the filename of this manifest.

public getFilename() : string
Return values
string

getHashes()

Return the payload and hashes as an associative array.

public getHashes() : array<string|int, mixed>
Return values
array<string|int, mixed>

Array of paths => hashes

getWarnings()

Return the array of warnings.

public getWarnings() : array<string|int, mixed>
Return values
array<string|int, mixed>

update()

Update the hashes for each path.

public update() : void
Return values
void

validate()

Compare file hashes against what is on disk.

public validate() : void
Return values
void

addError()

Add an error using the current filename.

protected addError(string $message) : void
Parameters
$message : string

The error text.

Return values
void

addWarning()

Add a warning using the current filename.

protected addWarning(string $message) : void
Parameters
$message : string

The error text.

Return values
void

calculateHash()

Calculate the hash of the file.

protected calculateHash(string $file) : string
Parameters
$file : string

Absolute path to the file.

Return values
string

The hash.

getPhpHashName()

Needed to account for differences in PHP hash to BagIt hash naming.

protected getPhpHashName() : string

i.e. BagIt sha3512 -> PHP sha3-512

Return values
string

the PHP hash name for the internal hash encoding.

loadFile()

Load the paths and hashes from the file on disk, does not validate.

protected loadFile() : void
Tags
throws
FilesystemException

Unable to read manifest file.

Return values
void

writeToDisk()

Utility to recreate the manifest file using the currently stored hashes.

protected writeToDisk() : void
Tags
throws
FilesystemException

If we can't write the manifest files.

Return values
void

addLoadError()

Add a load error using the current filename. This is only erased on a new load.

private addLoadError(string $message) : void
Parameters
$message : string

The error text.

Return values
void

addLoadWarning()

Add a load warning using the current filename. This is only erased on a new load.

private addLoadWarning(string $message) : void
Parameters
$message : string

The error text.

Return values
void

addToNormalizedList()

Add a path to the list of normalized paths.

private addToNormalizedList(string $path) : void
Parameters
$path : string

The normalized path.

Return values
void

checkIncomingFilePath()

Does validation on incoming file paths.

private checkIncomingFilePath(string $filepath, int $lineCount) : void
Parameters
$filepath : string

The file path to be checked.

$lineCount : int

The line of the manifest we are currently checking.

Return values
void

cleanUpRelPath()

Clean up file paths to remove extraneous periods, double periods and slashes

private cleanUpRelPath(string $filepath) : string
Parameters
$filepath : string

The relative file path.

Return values
string

The cleaned up relative file path or blank if not in the bag Root.

isTagManifest()

Is the filename match a tag manifest file?

private isTagManifest(string $filepath) : bool
Parameters
$filepath : string

The file path.

Return values
bool

True if it is a tagmanifest file.

matchNormalizedList()

Compare a path against a list of normalized paths and look for matches.

private matchNormalizedList(string $path) : bool
Parameters
$path : string

The normalized path to look for.

Return values
bool

True if there is a match.

normalizePath()

Normalize a path for character representation and case.

private normalizePath(string $path) : string
Parameters
$path : string

The path.

Return values
string

The normalized path.

resetLoadIssues()

Utility to reset the load issues construct.

private resetLoadIssues() : void
Return values
void

Search results