Properties

$debug

$debug : boolean

Debug mode switch.

Type

boolean

$created

$created : boolean

Allows to keep track of the corresponding repository resource state: - null - unknown - true - recent call to updateRms() created the repository resource - false - repository resource already existed uppon last updateRms() call

Type

boolean

$id

$id : string

Entity id.

Type

string

$metadata

$metadata : \EasyRdf\Resource

External metadata to be merged with automatically generated one.

Type

\EasyRdf\Resource

$metadataPreserve

$metadataPreserve : array

List of automaticaly generated metadata properties to be preserved while merging with external metadata.

Type

array

$pathEncoding

$pathEncoding : string

Detected operating system path enconding.

Type

string

$path

$path : string

File path

Type

string

$metaLookup

$metaLookup : \acdhOeaw\util\metaLookup\metaLookupInterface

Metadata lookup object to be used for metadata resoultion

Type

\acdhOeaw\util\metaLookup\metaLookupInterface

$metaLookupRequire

$metaLookupRequire : boolean

should metadata operations fail when no external metadata can be found

Type

boolean

$class

$class : string

RDF class to be set as a this file's type.

Type

string

$parent

$parent : string

URI of the resource which should be set as this file's parent (cfg::fedoraRelProp is used).

Type

string

Methods

__construct()

__construct(\acdhOeaw\fedora\Fedora  $fedora, \acdhOeaw\schema\file\type  $id, string  $class = null, string  $parent = null) 

Creates an object representing a file (or a directory) in a filesystem.

Parameters

\acdhOeaw\fedora\Fedora $fedora

repository connection object

\acdhOeaw\schema\file\type $id

file path

string $class

RDF class to be used as a repository resource type

string $parent

URI of a repository resource being parent of created one

getMetadata()

getMetadata() : Resource

Creates RDF metadata for a file.

Can use metadata lookup mechanism - see the setMetaLookup() method.

Returns

Resource

getResource()

getResource(boolean  $create = true, boolean  $uploadBinary = true) : \acdhOeaw\fedora\FedoraResource

Returns repository resource representing given real-world entity.

If it does not exist, it can be created.

Parameters

boolean $create

should repository resource be created if it does not exist?

boolean $uploadBinary

should binary data of the real-world entity be uploaded uppon repository resource creation?

Returns

\acdhOeaw\fedora\FedoraResource

getId()

getId() : string

Returns primary id of the real-world entity stored in this object (as it was set up in the object contructor).

Please do not confuse this id with the random internal ACDH repo id.

Returns

string

getIds()

getIds() : array

Returns all known ids

Returns

array —

list of all ids

updateRms()

updateRms(boolean  $create = true, boolean  $uploadBinary = true, string  $path = '/') : \acdhOeaw\fedora\FedoraResource

Updates repository resource representing a real-world entity stored in this object.

Parameters

boolean $create

should repository resource be created if it does not exist?

boolean $uploadBinary

should binary data of the real-world entity be uploaded uppon repository resource creation?

string $path

where to create a resource (if it does not exist). If it it ends with a "/", the resource will be created as a child of a given collection). All the parents in the Fedora resource tree have to exist (you can not create "/foo/bar" if "/foo" does not exist already).

Returns

\acdhOeaw\fedora\FedoraResource

getCreated()

getCreated() : boolean

Informs about the corresponding repository resource state uppon last call to the `updateRms()` method: - null - the updateRms() was not called yet - true - repository resource was created by last call to the updateRms() - false - repository resource already existed uppoin last call to the updateRms()

Returns

boolean

setMetadata()

setMetadata(Resource  $meta, array  $preserve = array()) 

Sets an external metadata to be appended to automatically generated ones.

If a given metatada property exists both in automatically generated and provided metadata, then the final result depends on the $preserve parameter:

  • if the property is listed in the $preserve array, both automatically generated and provided values will be kept
  • if not, only values from provided metadata will be kept and automatically generated ones will be skipped

Parameters

Resource $meta

external metadata

array $preserve

list of metadata properties to be kept - see above

createNewVersion()

createNewVersion(boolean  $uploadBinary = true, string  $path = '/', boolean  $pidPass = false) : \acdhOeaw\fedora\FedoraResource

Creates a new version of the resource. The new version inherits all IDs but the UUID and epic PIDs. The old version looses all IDs but the UUID and spic PIDs. It also looses all RC::relProp() connections with collections.

The old and the new resource are linked with cfg:fedoraIsNewVersionProp and cfg:fedoraIsOldVersionProp.

Parameters

boolean $uploadBinary

should binary data of the real-world entity be uploaded uppon repository resource creation?

string $path

where to create a resource (if it does not exist). If it it ends with a "/", the resource will be created as a child of a given collection). All the parents in the Fedora resource tree have to exist (you can not create "/foo/bar" if "/foo" does not exist already).

boolean $pidPass

should PIDs (epic handles) be migrated to the new version (true) or kept by the old one (false)

Returns

\acdhOeaw\fedora\FedoraResource

old version resource

sanitizePath()

sanitizePath(string  $path, string  $pathEncoding = null) : string

Sanitizes file path - turns all \ into / and assures it is UTF-8 encoded.

Parameters

string $path
string $pathEncoding

Returns

string

getRelPath()

getRelPath(string  $fullPath) 

Extracts relative path from a full path (by skipping cfg:containerDir)

Parameters

string $fullPath

setMetaLookup()

setMetaLookup(\acdhOeaw\util\metaLookup\MetaLookupInterface  $metaLookup, boolean  $require = false) 

Sets a metadata lookup object to be used for searching for file's metadata which can not be automatically derived from the file itself.

Metadata found using metadata lookup have precedense over metadata automatically derived from the file.

Parameters

\acdhOeaw\util\metaLookup\MetaLookupInterface $metaLookup

metadata lookup object

boolean $require

should metadata operations fail when no external metadata can be found

getMime()

getMime() : string

Returns file's mime type

Returns

string

findResource()

findResource(boolean  $create = true, boolean  $uploadBinary = true, string  $path = '') : boolean

Tries to find a repository resource representing a given object.

Parameters

boolean $create

should repository resource be created if it was not found?

boolean $uploadBinary

should binary data of the real-world entity be uploaded uppon repository resource creation?

string $path

where to create a resource (if it does not exist). If it it ends with a "/", the resource will be created as a child of a given collection). All the parents in the Fedora resource tree have to exist (you can not create "/foo/bar" if "/foo" does not exist already).

Returns

boolean —

if a repository resource was found

createResource()

createResource(Resource  $meta, boolean  $uploadBinary, string  $path) 

Creates a Fedora resource

Parameters

Resource $meta
boolean $uploadBinary
string $path

getBinaryData()

getBinaryData() : string

Returns file path (cause path is supported by the `Fedora->create()`).

Returns

string

mergeMetadata()

mergeMetadata(Resource  $current, Resource  $new) : Resource

Merges metadata coming from the Fedora and generated by the class.

Preserves the resource title if it already exists.

Parameters

Resource $current

current Fedora resource metadata

Resource $new

metadata generated by the class

Returns

Resource —

final metadata

detectPathEncoding()

detectPathEncoding() 

Tries to detect path encoding used in the operating system by looking into locale settings.

Throws

\RuntimeException