Webdav: ezcWebdavFileBackend
[ ]
[ Clients ] [ Plugin architecture ]
[ ]
[ ]
[ ]
[ ]
Class: ezcWebdavFileBackend
|
File system based backend. [
source]
Implemented Interfaces
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.
Parents
ezcWebdavBackend
|
--ezcWebdavSimpleBackend
|
--ezcWebdavFileBackend
Inherited Constants
From
ezcWebdavBackend:
Member Variables
|
protected array(int=>string) |
$handledLiveProperties
= array( 'getcontentlength', 'getlastmodified', 'creationdate', 'displayname', 'getetag', 'getcontenttype', 'resourcetype', 'supportedlock', 'lockdiscovery', )
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. |
Method Summary
|
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. |
Inherited Methods
From
ezcWebdavSimpleBackend :
From
ezcWebdavBackend :
Methods
__construct
void __construct(
string
$root )
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.
Parameters
| Name |
Type |
Description |
$root |
string |
|
Throws
| Class | Description |
ezcBaseFilePermissionException |
if the given $root is not readable. |
ezcBaseFileNotFoundException |
if the given $root does not exist or is not a directory. |
acquireLock
void acquireLock(
[bool
$readOnly = false] )
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.
Parameters
| Name |
Type |
Description |
$readOnly |
bool |
|
checkDeleteRecursive
array checkDeleteRecursive(
string
$source )
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.
Parameters
| Name |
Type |
Description |
$source |
string |
|
copy
Serves COPY requests.
This method acquires the internal lock of the backend, dispatches to
ezcWebdavSimpleBackend to perform the operation and releases the lock afterwards.
Parameters
Redefinition of
copyRecursive
array copyRecursive(
string
$source, string
$destination, [int
$depth = ezcWebdavRequest::DEPTH_INFINITY] )
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.
Parameters
| Name |
Type |
Description |
$source |
string |
|
$destination |
string |
|
$depth |
int |
|
createCollection
void createCollection(
string
$path )
Creates a new collection.
Creates a new collection at the given $path.
Parameters
| Name |
Type |
Description |
$path |
string |
|
Redefinition of
createResource
void createResource(
string
$path, [string
$content = null] )
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.
Parameters
| Name |
Type |
Description |
$path |
string |
|
$content |
string |
|
Redefinition of
delete
Serves DELETE requests.
This method acquires the internal lock of the backend, dispatches to
ezcWebdavSimpleBackend to perform the operation and releases the lock afterwards.
Parameters
Redefinition of
freeLock
void freeLock(
)
Free lock.
Frees the lock after the operation has been finished.
get
Serves GET requests.
This method acquires the internal lock of the backend, dispatches to
ezcWebdavSimpleBackend to perform the operation and releases the lock afterwards.
Parameters
Redefinition of
getAllProperties
Returns all properties for a resource.
Parameters
| Name |
Type |
Description |
$path |
string |
|
Redefinition of
getCollectionMembers
array(ezcWebdavResource|ezcWebdavCollection) getCollectionMembers(
string
$path )
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.
Parameters
| Name |
Type |
Description |
$path |
string |
|
Redefinition of
getETag
void getETag(
mixed
$path )
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:
- getcontentlength
- getlastmodified
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.
Parameters
| Name |
Type |
Description |
$path |
mixed |
|
Redefinition of
getMimeType
string getMimeType(
string
$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'.
Parameters
| Name |
Type |
Description |
$path |
string |
|
getProperty
ezcWebdavProperty getProperty(
string
$path, string
$propertyName, [string
$namespace = 'DAV:'] )
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.
Parameters
| Name |
Type |
Description |
$path |
string |
|
$propertyName |
string |
|
$namespace |
string |
|
Redefinition of
getPropertyStorage
Returns the property storage for a resource.
Parameters
| Name |
Type |
Description |
$path |
string |
|
getPropertyStoragePath
string getPropertyStoragePath(
string
$path )
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.
Parameters
| Name |
Type |
Description |
$path |
string |
|
getResourceContents
string getResourceContents(
string
$path )
Returns the contents of a resource.
This method returns the content of the resource identified by $path as a string.
Parameters
| Name |
Type |
Description |
$path |
string |
|
Redefinition of
head
Serves HEAD requests.
This method acquires the internal lock of the backend, dispatches to
ezcWebdavSimpleBackend to perform the operation and releases the lock afterwards.
Parameters
Redefinition of
isCollection
bool isCollection(
string
$path )
Returns if resource is a collection.
Returns if the resource identified by $path is a collection resource (true) or a non-collection one (false).
Parameters
| Name |
Type |
Description |
$path |
string |
|
Redefinition of
lock
void lock(
int
$waitTime, int
$timeout )
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.
Parameters
| Name |
Type |
Description |
$waitTime |
int |
|
$timeout |
int |
|
makeCollection
Serves MKCOL (make collection) requests.
This method acquires the internal lock of the backend, dispatches to
ezcWebdavSimpleBackend to perform the operation and releases the lock afterwards.
Parameters
Redefinition of
move
Serves MOVE requests.
This method acquires the internal lock of the backend, dispatches to
ezcWebdavSimpleBackend to perform the operation and releases the lock afterwards.
Parameters
Redefinition of
nodeExists
bool nodeExists(
string
$path )
Returns if a resource exists.
Returns if a the resource identified by $path exists.
Parameters
| Name |
Type |
Description |
$path |
string |
|
Redefinition of
performCopy
array(ezcWebdavErrorResponse) performCopy(
string
$fromPath, string
$toPath, [int
$depth = ezcWebdavRequest::DEPTH_INFINITY] )
Copies resources recursively from one path to another.
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.
Parameters
| Name |
Type |
Description |
$fromPath |
string |
|
$toPath |
string |
|
$depth |
int |
|
Redefinition of
performDelete
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.
Parameters
| Name |
Type |
Description |
$path |
string |
|
Redefinition of
propFind
Serves PROPFIND requests.
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.
Parameters
Redefinition of
propPatch
Serves PROPPATCH requests.
This method acquires the internal lock of the backend, dispatches to
ezcWebdavSimpleBackend to perform the operation and releases the lock afterwards.
Parameters
Redefinition of
put
Serves PUT requests.
This method acquires the internal lock of the backend, dispatches to
ezcWebdavSimpleBackend to perform the operation and releases the lock afterwards.
Parameters
Redefinition of
removeProperty
Manually removes a property from a resource.
Removes the given $property form the resource identified by $path.
Parameters
Redefinition of
resetProperties
Resets the property storage for a resource.
Discardes the current
ezcWebdavPropertyStorage of the resource identified by $path and replaces it with the given $properties.
Parameters
Redefinition of
setProperty
Manually sets a property on a resource.
Sets the given $propertyBackup for the resource identified by $path.
Parameters
Redefinition of
setResourceContents
void setResourceContents(
string
$path, string
$content )
Sets the contents of a resource.
This method replaces the content of the resource identified by $path with the submitted $content.
Parameters
| Name |
Type |
Description |
$path |
string |
|
$content |
string |
|
Redefinition of
storeProperties
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.
Parameters
unlock
void unlock(
)
Removes the lock.
Last updated: Mon, 21 Dec 2009