Properties

$debug

$debug : boolean

Should debug messages be generated when searching for resources

Type

boolean

$debugSparql

$debugSparql : boolean

Should debug messages be generated when running SPARQL queries

Type

boolean

$apiUrl

$apiUrl : string

Fedora API base URL

Type

string

$txUrl

$txUrl : string

Current transaction URI

Type

string

$client

$client : \GuzzleHttp\Client

HTTP client object

Type

\GuzzleHttp\Client

$txTimestamp

$txTimestamp : integer

Timestamp of the last transaction prolongation.

Type

integer

$txKeepAlive

$txKeepAlive : integer

Number of seconds between automatic transaction prolongation.

Type

integer

$defaultCollection

$defaultCollection : string

Default location for creating resources.

Type

string

$resToReindex

$resToReindex : array

If a resource was deleted and recreated within the same transaction, the triplestore integration plugin doesn't index it. Therefore such resources must be forecefully reindexed after transaction commit.

Type

array

$sparqlNTries

$sparqlNTries : integer

Number of attempts to execute a SPARQL query

Type

integer

$txProcPid

$txProcPid : integer

PID of the process keeping transaction alive

Type

integer

$txProc

$txProc : \acdhOeaw\util\KeepTransactionAlive

KeepTransactionAlive object (used when pcntl_fork() is not available, e.g.

on Windows).

Type

\acdhOeaw\util\KeepTransactionAlive

Methods

attachData()

attachData(\GuzzleHttp\Psr7\Request  $request,   $body) : \GuzzleHttp\Psr7\Request

Attaches binary content to a given Guzzle HTTP request

Parameters

\GuzzleHttp\Psr7\Request $request

HTTP request

$body

binary content to be attached It can be a file name, an URL, an array or a normal string. If it is an URL, a "redirecting Fedora resource" will be created. If it is an array, it should contain fields: contentType, filename, data

Returns

\GuzzleHttp\Psr7\Request

__construct()

__construct() 

Creates Fedora connection object from a given configuration.

__destruct()

__destruct() 

Clean up

isAcdhId()

isAcdhId(string  $uri) : boolean

Checks if a given URI belongs to ACDH id namespace(s)

Parameters

string $uri

uri

Returns

boolean

__clearCache()

__clearCache() 

Clears local cache.

Should not be used in normal usage scenarios (but can be helpful e.g. while running tests).

__refreshCache()

__refreshCache() 

Forecefully reloads all cached resources' metadata.

Should not be used in normal usage scenarios (but can be helpful if resources were altered at a low level).

createResource()

createResource(\acdhOeaw\fedora\EasyRdf\Resource  $metadata, mixed  $data = '', string  $path = '', string  $method = 'POST') : \acdhOeaw\rms\FedoraResource

Creates a resource in the Fedora and returns corresponding Resource object

Parameters

\acdhOeaw\fedora\EasyRdf\Resource $metadata

resource metadata

mixed $data

optional resource data as a string, file name or an array: ['contentType' => 'foo', 'data' => 'bar', 'filename' => 'foo.bar']

string $path

optional Fedora resource path (see also the $method parameter)

string $method

creation method to use - POST or PUT, by default POST

Throws

\BadMethodCallException

Returns

\acdhOeaw\rms\FedoraResource

sendRequest()

sendRequest(\GuzzleHttp\Psr7\Request  $request, array  $options = array()) : \GuzzleHttp\Psr7\Response

Sends a given HTTP request to the Fedora.

Switches most important errors into specific error classes.

Parameters

\GuzzleHttp\Psr7\Request $request

request to be send

array $options

Guzzle request options (see http://docs.guzzlephp.org/en/stable/request-options.html)

Throws

\acdhOeaw\fedora\exceptions\Deleted
\acdhOeaw\fedora\exceptions\NotFound
\GuzzleHttp\Exception\RequestException

Returns

\GuzzleHttp\Psr7\Response

getResourceByUri()

getResourceByUri(string  $uri) : \acdhOeaw\fedora\FedoraResource

Returns a FedoraResource based on a given URI.

Request URI is imported into the current connection meaning base Fedora API URL will and the current transaction URI (if there is an active transaction) will replace ones in passed URI.

It is not checked if a resource with a given URI exists.

Parameters

string $uri

Returns

\acdhOeaw\fedora\FedoraResource

getResourceById()

getResourceById(string  $id, boolean  $checkIfExist = true) : \acdhOeaw\fedora\FedoraResource

Finds Fedora resources with a given id property value (as it is defined by the "fedoraIdProp" configuration option - see the init() method).

If there is no or are many such resources, an error is thrown.

Parameters

string $id
boolean $checkIfExist

should we make sure resource was not deleted during the current transaction

Throws

\acdhOeaw\fedora\exceptions\NotFound
\acdhOeaw\fedora\exceptions\AmbiguousMatch

Returns

\acdhOeaw\fedora\FedoraResource

getResourceByMetadata()

getResourceByMetadata(Resource  $metadata, boolean  $checkIfExist = true) : \acdhOeaw\fedora\type

Extracts id properties form metadata based on the "fedoraIdProp" configuration property and calls `getResourceByIds()`

Parameters

Resource $metadata
boolean $checkIfExist

should we make sure resource was not deleted during the current transaction

Returns

\acdhOeaw\fedora\type

getResourceByIds()

getResourceByIds(array  $ids, boolean  $checkIfExist = true) : \acdhOeaw\fedora\FedoraResource

Finds Fedora resources matching any of provided ids.

Parameters

array $ids
boolean $checkIfExist

should we make sure resource was not deleted during the current transaction

Throws

\acdhOeaw\fedora\exceptions\NotFound
\acdhOeaw\fedora\exceptions\AmbiguousMatch

Returns

\acdhOeaw\fedora\FedoraResource

getResourcesByProperty()

getResourcesByProperty(string  $property, string  $value = '', boolean  $checkIfExist = true) : array

Finds all Fedora resources having a given RDF property value.

If the value is not provided, all resources with a given property set (to any value) are returned.

Be aware that all property values introduced during the transaction are not taken into account (see documentation of the begin() method)

Parameters

string $property

fully qualified property URI

string $value

optional property value

boolean $checkIfExist

should we make sure resource was not deleted during the current transaction

Returns

array

getResourcesByPropertyRegEx()

getResourcesByPropertyRegEx(string  $property, string  $regEx, string  $flags = 'i', boolean  $checkIfExist = true) : array

Finds all Fedora resources with a given RDF property matching given regular expression.

Be aware that all property values introduced during the transaction are not taken into account (see documentation of the begin() method)

Parameters

string $property

fully qualified property URI

string $regEx

regular expression to match against

string $flags

regular expression flags (by default "i" - case insensitive)

boolean $checkIfExist

should we make sure resource was not deleted during the current transaction

Returns

array

getResourcesByQuery()

getResourcesByQuery(\acdhOeaw\fedora\metadataQuery\Query  $query, string  $resVar = '?res', boolean  $checkIfExist = true) : array

Finds all Fedora resources satisfying a given SPARQL query.

Be aware that the triplestore state is not affected by all actions performed during the active transaction.

Parameters

\acdhOeaw\fedora\metadataQuery\Query $query

SPARQL query fetching resources from the triplestore

string $resVar

name of the SPARQL variable containing resource URIs

boolean $checkIfExist

should we make sure resource was not deleted during the current transaction

Returns

array

runQuery()

runQuery(\acdhOeaw\fedora\metadataQuery\Query  $query) : \EasyRdf\Sparql\Result

Runs a SPARQL query defined by a Query object against repository triplestore.

Parameters

\acdhOeaw\fedora\metadataQuery\Query $query

query to run

Returns

\EasyRdf\Sparql\Result

runSparql()

runSparql(string  $query, integer  $nTries = null) : \EasyRdf\Sparql\Result

Runs a SPARQL against repository triplestore.

Parameters

string $query

SPARQL query to run

integer $nTries

how many times request should be repeated in case of error before giving up

Returns

\EasyRdf\Sparql\Result

sanitizeUri()

sanitizeUri(string  $uri) : string

Adjusts URI to the current object state by setting up the proper base URL and the transaction id.

Parameters

string $uri

resource URI

Returns

string

standardizeUri()

standardizeUri(string  $uri) : string

Transforms an URI into "a canonical form" used in the triplestore to denote triples subject.

Parameters

string $uri

URI to transform

Returns

string

begin()

begin(integer  $keepAliveTimeout = 30) 

Starts new Fedora transaction.

Only one transaction can be opened at the same time, so make sure you committed previous transactions before starting a new one.

Be aware that all metadata modified during the transaction will be not visible in the triplestore coupled with the Fedora until the transaction is committed.

Parameters

integer $keepAliveTimeout

Automatic transaction prolongment timeout (see the prolong() method) - if a Fedora REST API is called and at least $keepAliveTimeout seconds passed since last prolongation, the transaction will be automatically prolonged.

rollback()

rollback() 

Rolls back the current Fedora transaction.

prolong()

prolong(string  $txUrl = null) 

Fedora transactions automatically expire after 3 minutes. If you want a transaction to be kept longer it must be manually prolonged. This method does it for you.

Parameters

string $txUrl

optional transaction URL. If not provided, current transaction URL is used.

setTransactionId()

setTransactionId(string  $txUrl) 

Overrides the transaction URI to be used by the Fedora connection.

Use with care.

Parameters

string $txUrl

commit()

commit() 

Commits the current Fedora transaction.

After the commit all the metadata modified during the transaction will be finally available in the triplestore associated with the Fedora.

inTransaction()

inTransaction() : boolean

Returns true if a Fedora transaction is opened and false otherwise.

Returns

boolean

fixMetadataReferences()

fixMetadataReferences(Resource  $meta, array  $skipProperties = array()) : Resource

Tries to switch references to all repository resources into their UUIDs.

Changes are done in-place!

Parameters

Resource $meta

metadata to apply changes to

array $skipProperties

list of properties which should not be processed (other than IDs which are always excluded)

Returns

Resource

verifyResources()

verifyResources(array  $resources, boolean  $force = false) : array

Removes from an array resources which do not exist anymore.

Parameters

array $resources
boolean $force

should resource be always checked (true) or maybe it is enough if metadata were already fetched during this session (false)

Throws

\acdhOeaw\fedora\ClientException

Returns

array

reindexResources()

reindexResources() 

Reindexes resources scheduled for reindexing by issuing a dummy metadata update.

keepTransactionAlive()

keepTransactionAlive() 

Keeps transaction alive (used in separate process)

killKeepTransactionAlive()

killKeepTransactionAlive() 

Ends process keeping transaction alive