File system based backend.
This backend serves WebDAV resources from a directory structure in the file system. It simply handles directories as collection resources and files as non-collection resources. The path to server resources from is defined during construction.
Live properties are partly determined from the file systems itself (like ezcWebdavGetContentLengthProperty), others need to be stored like dead properties. This backend uses a special path for each resource to store this information in its XML representation.
Source for this file: /Webdav/src/backends/file.php
ezcWebdavBackend | --ezcWebdavSimpleBackend | --ezcWebdavFileBackend
Version: | //autogentag// |
From ezcWebdavBackend: | |
---|---|
ezcWebdavBackend::COMPRESSION_BZIP2
|
Backend has native support for bzip2 compression. |
ezcWebdavBackend::COMPRESSION_GZIP
|
Backend has native support for gzip compression. |
ezcWebdavBackend::CUSTOM_LOCK
|
Backend performs locking itself - no handling by server is required. |
ezcWebdavBackend::MULTIPART
|
Backend has native support for multipart requests. |
ezcWebdavBackend::PARTIAL
|
Backend has native support for partial requests. |
protected array(int=>string) |
$handledLiveProperties
= array(
Names of live properties from the DAV: namespace which will be handled live, and should not be stored like dead properties. |
protected int |
$lockLevel
= 0
Keeps track of the lock level. Each time the lock() method is called, this counter is raised by 1. if it was 0 before, the actual locking mechanism gets into action, otherwise just the counter is raised. The lock is physically only freed, if this counter is 0. This mechanism allows nested locking, as it is necessary, if the lock plugin locks this backend external, but interal locking needs still to be supported. |
protected ezcWebdavFileBackendOptions |
$options
Options. |
protected string |
$root
Root directory to serve content from. All paths are seen relatively to this one. |
public void |
__construct(
$root
)
Creates a new backend instance. |
protected void |
acquireLock(
[ $readOnly
= false] )
Wait and get lock for complete directory tree. |
public array |
checkDeleteRecursive(
$source
)
Returns if everything below a path can be deleted recursively. |
public ezcWebdavResponse |
copy(
$request
)
Serves COPY requests. |
public array |
copyRecursive(
$source
, $destination
, [ $depth
= ezcWebdavRequest::DEPTH_INFINITY] )
Recursively copy a file or directory. |
protected void |
createCollection(
$path
)
Creates a new collection. |
protected void |
createResource(
$path
, [ $content
= null] )
Creates a new resource. |
public ezcWebdavResponse |
delete(
$request
)
Serves DELETE requests. |
protected void |
freeLock(
)
Free lock. |
public ezcWebdavResponse |
get(
$request
)
Serves GET requests. |
public ezcWebdavPropertyStorage |
getAllProperties(
$path
)
Returns all properties for a resource. |
protected array(ezcWebdavResource|ezcWebdavCollection) |
getCollectionMembers(
$path
)
Returns members of collection. |
protected void |
getETag(
$path
)
Returns the etag representing the current state of $path. |
protected string |
getMimeType(
$path
)
Returns the mime type of a resource. |
public ezcWebdavProperty |
getProperty(
$path
, $propertyName
, [ $namespace
= 'DAV:'] )
Returns a property of a resource. |
protected ezcWebdavBasicPropertyStorage |
getPropertyStorage(
$path
)
Returns the property storage for a resource. |
protected string |
getPropertyStoragePath(
$path
)
Returns the storage path for a property. |
protected string |
getResourceContents(
$path
)
Returns the contents of a resource. |
public ezcWebdavResponse |
head(
$request
)
Serves HEAD requests. |
protected bool |
isCollection(
$path
)
Returns if resource is a collection. |
public void |
lock(
$waitTime
, $timeout
)
Locks the backend. |
public ezcWebdavResponse |
makeCollection(
$request
)
Serves MKCOL (make collection) requests. |
public ezcWebdavResponse |
move(
$request
)
Serves MOVE requests. |
protected bool |
nodeExists(
$path
)
Returns if a resource exists. |
protected array(ezcWebdavErrorResponse) |
performCopy(
$fromPath
, $toPath
, [ $depth
= ezcWebdavRequest::DEPTH_INFINITY] )
Copies resources recursively from one path to another. |
protected ezcWebdavErrorResponse |
performDelete(
$path
)
Deletes everything below a path. |
public ezcWebdavResponse |
propFind(
$request
)
Serves PROPFIND requests. |
public ezcWebdavResponse |
propPatch(
$request
)
Serves PROPPATCH requests. |
public ezcWebdavResponse |
put(
$request
)
Serves PUT requests. |
public bool |
removeProperty(
$path
, $property
)
Manually removes a property from a resource. |
public bool |
resetProperties(
$path
, $storage
)
Resets the property storage for a resource. |
public bool |
setProperty(
$path
, $property
)
Manually sets a property on a resource. |
protected void |
setResourceContents(
$path
, $content
)
Sets the contents of a resource. |
protected void |
storeProperties(
$path
, $storage
)
Stores properties for a resource. |
public void |
unlock(
)
Removes the lock. |
From ezcWebdavSimpleBackend | |
---|---|
protected ezcWebdavErrorResponse|null |
ezcWebdavSimpleBackend::checkIfMatchHeaders()
Checks the If-Match and If-None-Match headers. |
public ezcWebdavResponse |
ezcWebdavSimpleBackend::copy()
Serves COPY requests. |
protected abstract void |
ezcWebdavSimpleBackend::createCollection()
Create a new collection. |
protected abstract void |
ezcWebdavSimpleBackend::createResource()
Create a new resource. |
public ezcWebdavResponse |
ezcWebdavSimpleBackend::delete()
Serves DELETE requests. |
protected ezcWebdavMultistatusResponse |
ezcWebdavSimpleBackend::fetchAllProperties()
Returns all available properties for a resource. |
protected ezcWebdavResponse |
ezcWebdavSimpleBackend::fetchProperties()
Returns properties, fetched by name. |
protected ezcWebdavResponse |
ezcWebdavSimpleBackend::fetchPropertyNames()
Returns names of all available properties for a resource. |
public ezcWebdavResponse |
ezcWebdavSimpleBackend::get()
Serves GET requests. |
public abstract ezcWebdavPropertyStorage |
ezcWebdavSimpleBackend::getAllProperties()
Returns all properties for a resource. |
protected abstract array(ezcWebdavResource|ezcWebdavCollection) |
ezcWebdavSimpleBackend::getCollectionMembers()
Returns members of collection. |
protected void |
ezcWebdavSimpleBackend::getETag()
Returns the etag representing the current state of $path. |
public int |
ezcWebdavSimpleBackend::getFeatures()
Returns additional features supported by the backend. |
protected array(ezcWebdavResource|ezcWebdavCollection) |
ezcWebdavSimpleBackend::getNodes()
Returns all child nodes. |
public abstract ezcWebdavProperty |
ezcWebdavSimpleBackend::getProperty()
Returns a property of a resource. |
protected abstract string |
ezcWebdavSimpleBackend::getResourceContents()
Returns the content of a resource. |
public ezcWebdavResponse |
ezcWebdavSimpleBackend::head()
Serves HEAD requests. |
protected abstract bool |
ezcWebdavSimpleBackend::isCollection()
Returns if resource is a collection. |
public ezcWebdavResponse |
ezcWebdavSimpleBackend::makeCollection()
Serves MKCOL (make collection) requests. |
public ezcWebdavResponse |
ezcWebdavSimpleBackend::move()
Serves MOVE requests. |
protected abstract bool |
ezcWebdavSimpleBackend::nodeExists()
Returns if a resource exists. |
public ezcWebdavOptionsResponse |
ezcWebdavSimpleBackend::options()
Handles the OPTIONS request. |
protected abstract array(ezcWebdavErrorResponse) |
ezcWebdavSimpleBackend::performCopy()
Copies resources recursively from one path to another. |
protected abstract ezcWebdavMultitstatusResponse|null |
ezcWebdavSimpleBackend::performDelete()
Deletes everything below a path. |
public ezcWebdavResponse |
ezcWebdavSimpleBackend::propFind()
Serves PROPFIND requests. |
public ezcWebdavResponse |
ezcWebdavSimpleBackend::propPatch()
Serves PROPPATCH requests. |
public ezcWebdavResponse |
ezcWebdavSimpleBackend::put()
Serves PUT requests. |
public abstract bool |
ezcWebdavSimpleBackend::removeProperty()
Manually removes a property from a resource. |
public abstract bool |
ezcWebdavSimpleBackend::resetProperties()
Resets the property storage for a resource. |
public abstract bool |
ezcWebdavSimpleBackend::setProperty()
Manually sets a property on a resource. |
protected abstract void |
ezcWebdavSimpleBackend::setResourceContents()
Changes contents of a resource. |
From ezcWebdavBackend | |
public abstract ezcWebdavResponse |
ezcWebdavBackend::get()
Serves GET requests. |
public int |
ezcWebdavBackend::getFeatures()
Returns additional features supported by the backend. |
public abstract ezcWebdavResponse |
ezcWebdavBackend::head()
Serves HEAD requests. |
public ezcWebdavResponse |
ezcWebdavBackend::options()
Required method to serve OPTIONS requests. |
public ezcWebdavResponse |
ezcWebdavBackend::performRequest()
Performs the given request. |
public abstract ezcWebdavResponse |
ezcWebdavBackend::propFind()
Serves PROPFIND requests. |
public abstract ezcWebdavResponse |
ezcWebdavBackend::propPatch()
Serves PROPPATCH requests. |
Creates a new backend instance.
Creates a new backend to server WebDAV content from the file system path identified by $root. If the given path does not exist or is not a directory, an exception will be thrown.
Name | Type | Description |
---|---|---|
$root |
string |
Type | Description |
---|---|
ezcBaseFilePermissionException |
if the given $root is not readable. |
ezcBaseFileNotFoundException |
if the given $root does not exist or is not a directory. |
Wait and get lock for complete directory tree.
Acquire lock for the complete tree for read or write operations. This does not implement any priorities for operations, or check if several read operation may run in parallel. The plain locking should / could be extended by something more sophisticated.
If the tree already has been locked, the method waits until the lock can be acquired.
The optional second parameter $readOnly indicates wheather a read only lock should be acquired. This may be used by extended implementations, but it is not used in this implementation.
Name | Type | Description |
---|---|---|
$readOnly |
bool |
Returns if everything below a path can be deleted recursively.
Checks files and directories recursively and returns if everything can be deleted. Returns an empty array if no errors occured, and an array with the files which caused errors otherwise.
Name | Type | Description |
---|---|---|
$source |
string |
Serves COPY requests.
The method receives a ezcWebdavCopyRequest objects containing all relevant information obout the clients request and will return an instance of ezcWebdavErrorResponse on error or ezcWebdavCopyResponse on success. If only some operations failed, this method may return an instance of ezcWebdavMultistatusResponse.
This method acquires the internal lock of the backend, dispatches to ezcWebdavSimpleBackend to perform the operation and releases the lock afterwards.
Name | Type | Description |
---|---|---|
$request |
ezcWebdavCopyRequest |
Method | Description |
---|---|
ezcWebdavSimpleBackend::copy() |
Serves COPY requests. |
Recursively copy a file or directory.
Recursively copy a file or directory in $source to the given $destination. If a $depth is given, the operation will stop as soon as the given recursion depth is reached. A depth of -1 means no limit, while a depth of 0 means, that only the current file or directory will be copied, without any recursion.
Returns an empty array if no errors occured, and an array with the files which caused errors otherwise.
Name | Type | Description |
---|---|---|
$source |
string | |
$destination |
string | |
$depth |
int |
Creates a new collection.
Creates a new collection at the given $path.
Name | Type | Description |
---|---|---|
$path |
string |
Method | Description |
---|---|
ezcWebdavSimpleBackend::createCollection() |
Create a new collection. |
Creates a new resource.
Creates a new resource at the given $path, optionally with the given content. If $content is empty, an empty resource will be created.
Name | Type | Description |
---|---|---|
$path |
string | |
$content |
string |
Method | Description |
---|---|
ezcWebdavSimpleBackend::createResource() |
Create a new resource. |
Serves DELETE requests.
The method receives a ezcWebdavDeleteRequest objects containing all relevant information obout the clients request and will return an instance of ezcWebdavErrorResponse on error or ezcWebdavDeleteResponse on success.
This method acquires the internal lock of the backend, dispatches to ezcWebdavSimpleBackend to perform the operation and releases the lock afterwards.
Name | Type | Description |
---|---|---|
$request |
ezcWebdavDeleteRequest |
Method | Description |
---|---|
ezcWebdavSimpleBackend::delete() |
Serves DELETE requests. |
Free lock.
Frees the lock after the operation has been finished.
Serves GET requests.
The method receives a ezcWebdavGetRequest object containing all relevant information obout the clients request and will return an ezcWebdavErrorResponse instance on error or an instance of ezcWebdavGetResourceResponse or ezcWebdavGetCollectionResponse on success, depending on the type of resource that is referenced by the request.
This method acquires the internal lock of the backend, dispatches to ezcWebdavSimpleBackend to perform the operation and releases the lock afterwards.
Name | Type | Description |
---|---|---|
$request |
ezcWebdavGetRequest |
Method | Description |
---|---|
ezcWebdavSimpleBackend::get() |
Serves GET requests. |
Returns all properties for a resource.
Returns all properties for the resource identified by $path as a ezcWebdavBasicPropertyStorage.
Name | Type | Description |
---|---|---|
$path |
string |
Method | Description |
---|---|
ezcWebdavSimpleBackend::getAllProperties() |
Returns all properties for a resource. |
Returns members of collection.
Returns an array with the members of the collection identified by $path. The returned array can contain ezcWebdavCollection, and ezcWebdavResource instances and might also be empty, if the collection has no members.
Name | Type | Description |
---|---|---|
$path |
string |
Method | Description |
---|---|
ezcWebdavSimpleBackend::getCollectionMembers() |
Returns members of collection. |
Returns the etag representing the current state of $path.
Calculates and returns the ETag for the resource represented by $path. The ETag is calculated from the $path itself and the following properties, which are concatenated and md5 hashed:
This method can be overwritten in custom backend implementations to access the information needed directly without using the way around properties.
Custom backend implementations are encouraged to use the same mechanism (or this method itself) to determine and generate ETags.
Name | Type | Description |
---|---|---|
$path |
mixed |
Method | Description |
---|---|
ezcWebdavSimpleBackend::getETag() |
Returns the etag representing the current state of $path. |
Returns the mime type of a resource.
Return the mime type of the resource identified by $path. If a mime type extension is available it will be used to read the real mime type, otherwise the original mime type passed by the client when uploading the file will be returned. If no mimetype has ever been associated with the file, the method will just return 'application/octet-stream'.
Name | Type | Description |
---|---|---|
$path |
string |
Returns a property of a resource.
Returns the property with the given $propertyName, from the resource identified by $path. You may optionally define a $namespace to receive the property from.
Name | Type | Description |
---|---|---|
$path |
string | |
$propertyName |
string | |
$namespace |
string |
Method | Description |
---|---|
ezcWebdavSimpleBackend::getProperty() |
Returns a property of a resource. |
Returns the property storage for a resource.
Returns the ezcWebdavPropertyStorage instance containing the properties for the resource identified by $path.
Name | Type | Description |
---|---|---|
$path |
string |
Returns the storage path for a property.
Returns the file systems path where properties are stored for the resource identified by $path. This depends on the name of the resource.
Name | Type | Description |
---|---|---|
$path |
string |
Returns the contents of a resource.
This method returns the content of the resource identified by $path as a string.
Name | Type | Description |
---|---|---|
$path |
string |
Method | Description |
---|---|
ezcWebdavSimpleBackend::getResourceContents() |
Returns the content of a resource. |
Serves HEAD requests.
The method receives a ezcWebdavHeadRequest object containing all relevant information obout the clients request and will return an ezcWebdavErrorResponse instance on error or an instance of ezcWebdavHeadResponse on success.
This method acquires the internal lock of the backend, dispatches to ezcWebdavSimpleBackend to perform the operation and releases the lock afterwards.
Name | Type | Description |
---|---|---|
$request |
ezcWebdavHeadRequest |
Method | Description |
---|---|
ezcWebdavSimpleBackend::head() |
Serves HEAD requests. |
Returns if resource is a collection.
Returns if the resource identified by $path is a collection resource (true) or a non-collection one (false).
Name | Type | Description |
---|---|---|
$path |
string |
Method | Description |
---|---|
ezcWebdavSimpleBackend::isCollection() |
Returns if resource is a collection. |
Locks the backend.
Tries to lock the backend. If the lock is already owned by this process, locking is successful. If $timeout is reached before a lock could be acquired, an ezcWebdavLockTimeoutException is thrown. Waits $waitTime microseconds between attempts to lock the backend.
Name | Type | Description |
---|---|---|
$waitTime |
int | |
$timeout |
int |
Method | Description |
---|---|
ezcWebdavLockBackend::lock() |
Acquire a backend lock. |
Serves MKCOL (make collection) requests.
The method receives a ezcWebdavMakeCollectionRequest objects containing all relevant information obout the clients request and will return an instance of ezcWebdavErrorResponse on error or ezcWebdavMakeCollectionResponse on success.
This method acquires the internal lock of the backend, dispatches to ezcWebdavSimpleBackend to perform the operation and releases the lock afterwards.
Name | Type | Description |
---|---|---|
$request |
ezcWebdavMakeCollectionRequest |
Method | Description |
---|---|
ezcWebdavSimpleBackend::makeCollection() |
Serves MKCOL (make collection) requests. |
Serves MOVE requests.
The method receives a ezcWebdavMoveRequest objects containing all relevant information obout the clients request and will return an instance of ezcWebdavErrorResponse on error or ezcWebdavMoveResponse on success. If only some operations failed, this method may return an instance of ezcWebdavMultistatusResponse.
This method acquires the internal lock of the backend, dispatches to ezcWebdavSimpleBackend to perform the operation and releases the lock afterwards.
Name | Type | Description |
---|---|---|
$request |
ezcWebdavMoveRequest |
Method | Description |
---|---|
ezcWebdavSimpleBackend::move() |
Serves MOVE requests. |
Returns if a resource exists.
Returns if a the resource identified by $path exists.
Name | Type | Description |
---|---|---|
$path |
string |
Method | Description |
---|---|
ezcWebdavSimpleBackend::nodeExists() |
Returns if a resource exists. |
Copies resources recursively from one path to another.
Copies the resourced identified by $fromPath recursively to $toPath with the given $depth, where $depth is one of ezcWebdavRequest::DEPTH_ZERO, ezcWebdavRequest::DEPTH_ONE, ezcWebdavRequest::DEPTH_INFINITY.
Returns an array with ezcWebdavErrorResponses for all subtrees, where the copy operation failed. Errors for subsequent resources in a subtree should be ommitted.
If an empty array is return, the operation has been completed successfully.
Name | Type | Description |
---|---|---|
$fromPath |
string | |
$toPath |
string | |
$depth |
int |
Method | Description |
---|---|
ezcWebdavSimpleBackend::performCopy() |
Copies resources recursively from one path to another. |
Deletes everything below a path.
Deletes the resource identified by $path recursively. Returns an instance of ezcWebdavErrorResponse if the deletion failed, and null on success.
Name | Type | Description |
---|---|---|
$path |
string |
Method | Description |
---|---|
ezcWebdavSimpleBackend::performDelete() |
Deletes everything below a path. |
Serves PROPFIND requests.
The method receives a ezcWebdavPropFindRequest object containing all relevant information obout the clients request and will either return an instance of ezcWebdavErrorResponse to indicate an error or a ezcWebdavPropFindResponse on success. If the referenced resource is a collection or if some properties produced errors, an instance of ezcWebdavMultistatusResponse may be returned.
The ezcWebdavPropFindRequest object contains a definition to find one or more properties of a given collection or non-collection resource.
This method acquires the internal lock of the backend, dispatches to ezcWebdavSimpleBackend to perform the operation and releases the lock afterwards.
Name | Type | Description |
---|---|---|
$request |
ezcWebdavPropFindRequest |
Method | Description |
---|---|
ezcWebdavSimpleBackend::propFind() |
Serves PROPFIND requests. |
Serves PROPPATCH requests.
The method receives a ezcWebdavPropPatchRequest object containing all relevant information obout the clients request and will return an instance of ezcWebdavErrorResponse on error or a ezcWebdavPropPatchResponse response on success. If the referenced resource is a collection or if only some properties produced errors, an instance of ezcWebdavMultistatusResponse may be returned.
This method acquires the internal lock of the backend, dispatches to ezcWebdavSimpleBackend to perform the operation and releases the lock afterwards.
Name | Type | Description |
---|---|---|
$request |
ezcWebdavPropPatchRequest |
Method | Description |
---|---|
ezcWebdavSimpleBackend::propPatch() |
Serves PROPPATCH requests. |
Serves PUT requests.
The method receives a ezcWebdavPutRequest objects containing all relevant information obout the clients request and will return an instance of ezcWebdavErrorResponse on error or ezcWebdavPutResponse on success.
This method acquires the internal lock of the backend, dispatches to ezcWebdavSimpleBackend to perform the operation and releases the lock afterwards.
Name | Type | Description |
---|---|---|
$request |
ezcWebdavPutRequest |
Method | Description |
---|---|
ezcWebdavSimpleBackend::put() |
Serves PUT requests. |
Manually removes a property from a resource.
Removes the given $property form the resource identified by $path.
Name | Type | Description |
---|---|---|
$path |
string | |
$property |
ezcWebdavProperty |
Method | Description |
---|---|
ezcWebdavSimpleBackend::removeProperty() |
Manually removes a property from a resource. |
Resets the property storage for a resource.
Discardes the current ezcWebdavPropertyStorage of the resource identified by $path and replaces it with the given $properties.
Name | Type | Description |
---|---|---|
$path |
string | |
$storage |
ezcWebdavPropertyStorage |
Method | Description |
---|---|
ezcWebdavSimpleBackend::resetProperties() |
Resets the property storage for a resource. |
Manually sets a property on a resource.
Sets the given $propertyBackup for the resource identified by $path.
Name | Type | Description |
---|---|---|
$path |
string | |
$property |
ezcWebdavProperty |
Method | Description |
---|---|
ezcWebdavSimpleBackend::setProperty() |
Manually sets a property on a resource. |
Sets the contents of a resource.
This method replaces the content of the resource identified by $path with the submitted $content.
Name | Type | Description |
---|---|---|
$path |
string | |
$content |
string |
Method | Description |
---|---|
ezcWebdavSimpleBackend::setResourceContents() |
Changes contents of a resource. |
Stores properties for a resource.
Creates a new property storage file and stores the properties given for the resource identified by $path. This depends on the affected resource and the actual properties in the property storage.
Name | Type | Description |
---|---|---|
$path |
string | |
$storage |
ezcWebdavBasicPropertyStorage |
Removes the lock.
Method | Description |
---|---|
ezcWebdavLockBackend::unlock() |
Release the backend lock. |