ADD
ADD
Represents a FedoraResource containg ACL rules.
Allows manipulations like getting/setting metadata and updating resource contents.
$fedora : \acdhOeaw\fedora\Fedora
Fedora connection object used by this resource
$acl : \acdhOeaw\fedora\acl\WebAcl
Object providing ACL support.
__construct(\acdhOeaw\fedora\Fedora $fedora, string $uri = '')
Returns an object representing a FedoraResource containg ACL rules.
You can (and in fact must) use it to create new ACL rule resources. A corresponding resource in the Fedora will be created by a call to the save() method.
\acdhOeaw\fedora\Fedora | $fedora | Fedora connection object |
string | $uri | (optional) Fedora resource URI |
getFedora() : \acdhOeaw\fedora\Fedora
Returns the Fedora connection used by this object
delete(boolean $deep = false, boolean $children = false, boolean $references = false)
Removes the ACL rule from the Fedora
Please remember searching for children and references is done using a SPARQL query so any changes made since the beginning of the transaction won't be taken into account.
boolean | $deep | should tombstone resource will be deleted? |
boolean | $children | should children be removed? |
boolean | $references | should references to the resource be removed?
(applies also for children when |
setMetadata(\acdhOeaw\fedora\EasyRdf\Resource $metadata, boolean $fixReferences = false)
Replaces resource metadata with a given RDF graph.
New metadata are not automatically written back to the Fedora. Use the updateMetadata() method to write them back.
\acdhOeaw\fedora\EasyRdf\Resource | $metadata | |
boolean | $fixReferences | Should reference to other repository resources be switched into corresponding UUIDs? |
updateMetadata(string $mode = self::OVERWRITE)
Writes resource metadata back to the Fedora and then fetches them by calling getMetadata().
Do not be surprised that the metadata read back from the Fedora can (and for sure will) differ from the one written by you. This is because Fedora (and/or doorkeeper) will add/modify some triples (e.g. fedora:lastModified).
Be aware that as Fedora generates errors when you try to set properties
Fedora considers its private once, such properties will be ommited in the
update (see getSparqlTriples()
method documentation for details).
string | $mode | chooses the way the update is done: ADD simply adds current triples. All already existing triples (also old value of the triples you altered) are kept. UPDATE old values of already existing triples are updated with current values, new triples are added and all other triples are kept. OVERWRITE all existing triples are removed, then all current triples are added. |
getMetadata(boolean $force = false) : \EasyRdf\Resource
Returns resource metadata.
Fetches them from the Fedora if they were not fetched already.
A deep copy of metadata is returned meaning adjusting the returned object does not automatically affect the resource metadata. Use the setMetadata() method to write back the changes you made.
boolean | $force | enforce fetch from Fedora (when you want to make sure metadata are in line with ones in the Fedora or e.g. reset them back to their current state in Fedora) |
updateContent(mixed $data, boolean $convert = false)
Updates resource binary content in the Fedora.
If the resource is not a binary resource (in Fedora terms), it can be converted. This means the existing Fedora resource will be deleted and the new one will be created. This means the resource will change its Fedora URI but the id property indicated by the "fedoraIdProp" config option (see init()) will be preserved. This means until you are using the id property values (and not Fedora URIs) to denote resources in your metadata, your metadata consistency will be preserved.
mixed | $data | resource data as a string, file name or an array: ['contentType' => 'foo', 'data' => 'bar', 'filename' => 'baz.txt'] |
boolean | $convert | if metadata-only resource be automatically converted to a binary one |
getChildrenQuery() : \acdhOeaw\fedora\metadataQuery\Query
Returns the SPARQL query object returning resource's children.
It is assumed that child-parent relations are denoted by:
child -> config::relProp -> id <- config::idProp <- parent
metadata properties scheme.
getChildrenQueryParameter() : \acdhOeaw\fedora\metadataQuery\QueryParameter
Return the SPARQL query triple object denoting relation of being this resource's child
getFedoraChildren() : array
Returns all resource's Fedora children.
A Fedora child is a resource pointed by the ldp:contains triple. All Fedora children URIs are nested in the parent's URI path but the deepness of such nesting can vary (e.g. both http://a/b and http://a/b/c/d can be Fedora children of the http://a depenging on how they were created).
Fedora's parent-child relation is automatically maintained by the Fedora and depends on the way Fedora resources are created.
getChildrenByProperty(string $property, string $value = '') : array
Returns all resource's children having a given property or a given value of a given property.
It is assumed that child-parent relations are denoted by:
child -> config::relProp -> id <- config::idProp <- parent
metadata properties scheme.
string | $property | fully qualified URI of the property |
string | $value | property value (optional) |
getChildrenByPropertyRegEx(string $property, string $regEx, string $flags = 'i') : array
Returns all resource's children with a given property matching a given regular expression
It is assumed that child-parent relations are denoted by:
child -> config::relProp -> id <- config::idProp <- parent
metadata properties scheme.
string | $property | fully qualified URI of the property |
string | $regEx | regular expression to match |
string | $flags | regular expression flags |
getAcl(boolean $refresh = true) : \acdhOeaw\fedora\acl\WebAcl
Returns a WebAcl object for access rules manipulation.
boolean | $refresh | should the ACL collection and rules be refreshed or read from cache (there are many scenarios when reading requiring ACL data to be outdated so the default behaviour is to refresh) |
getDissServices(boolean $lazy = false) : array
Returns list of dissemination services available for a resource.
boolean | $lazy | when false returned array contains instances of \acdhOeaw\fedora\dissemination\Service, when true it contains dissemination service URIs |
addResource(\acdhOeaw\fedora\FedoraResource $res) : \acdhOeaw\fedora\acl\WebAclRule
Adds additional webacl:accessTo triple to the ACL rule.
\acdhOeaw\fedora\FedoraResource | $res | Fedora resource which URI will be added |
addClass(string $class) : \acdhOeaw\fedora\acl\WebAclRule
Adds additional webacl:accessToClass triple to the ACL rule.
string | $class | class URI |
addRole(string $type, string $name) : \acdhOeaw\fedora\acl\WebAclRule
Adds additional webacl:agent or webacl:agentClass triple to the ACL rule.
string | $type | WebAclRule::USER or WebAclRule::GROUP |
string | $name | user/group name/URI |
deleteRole(string $type, string $name) : \acdhOeaw\fedora\acl\WebAclRule
Removes corresponding `webacl:agent $name` or `webacl:agentClass $name` triple form the the current ACL rule.
string | $type | WebAclRule::USER or WebAclRule::GROUP |
string | $name | user/group name/URI |
setMode(string $mode) : \acdhOeaw\fedora\acl\WebAclRule
Sets value of the webacl:mode triple.
string | $mode | WebAclRule::READ or WebAclRule::WRITE |
save(string $location = null) : \acdhOeaw\fedora\FedoraResource
Saves the ACL rule.
If there is no corresponging Fedora resource, it is created as a Fedora
child of a resource denpted by the $location
parameter.
string | $location | URI of the parent resource (typically an ACL collection) |
loadMetadata(boolean $force = false)
Loads current metadata from the Fedora and parses read ACL triples.
boolean | $force | enforce fetch from Fedora (when you want to make sure metadata are in line with ones in the Fedora or e.g. reset them back to their current state in Fedora) |
getSparqlTriples(\EasyRdf\Resource $metadata) : string
Serializes metadata to a form suitable for Fedora's SPARQL-update query.
This means the "ntriples" format with subject URIs compliant with current Fedora connection and excluding properties Fedora reserves for itself (and rises errors when they are provided from the outside).
\EasyRdf\Resource | $metadata | metadata to serialize |
extractAcl(\GuzzleHttp\Psr7\Response $resp)
Fetches ACL URL from Fedora response headers and updates the `$aclUrl` property.
If new and old URLs differ, clears the $acl
property.
If no appropriate header is found clears the $aclUrl
and $acl
properties.
\GuzzleHttp\Psr7\Response | $resp | Fedora response |