org.abstracthorizon.danube.webdav.fs
Class FileSystemWebDAVResourceAdapter

java.lang.Object
  extended by org.abstracthorizon.danube.webdav.fs.FileSystemWebDAVResourceAdapter
All Implemented Interfaces:
ResourceAdapter

public class FileSystemWebDAVResourceAdapter
extends Object
implements ResourceAdapter

Simple file system resource adapter

Author:
Daniel Sendula

Field Summary
protected  DAVNamespace davNamespace
          Default DAV namespace
protected static ResponseProperty[] dirPropertyNames
          Default directory property names
protected static RequestProperty[] dirRequestProperties
          Default dir request properties
protected static ResponseProperty[] filePropertyNames
          Default file property names
protected static RequestProperty[] fileRequestProperties
          Default file request properties
protected  LockingMechanism lockingMechanism
          Locking mechanism to be used with this adapter
protected  NamespacesProvider namespacesProvider
          Namespace provider to be used with this adapter
protected  File path
          Root path of the files to be served
 
Constructor Summary
FileSystemWebDAVResourceAdapter()
          Constructor
FileSystemWebDAVResourceAdapter(File path)
          Constructor
 
Method Summary
 Object[] collectionElements(Object resource)
          Returns File objects of supplied resource directory
 void copy(Object source, Object destination, boolean recursive)
          Copies source file to destination file
 void delete(Object resource)
          Deletes a file
 boolean exists(Object resource)
          Returns true if file exists
 Object findParentResource(Object resource)
          Returns file's parent
 Object findResource(String path)
          Returns File object of given path startin from path
 RequestProperty[] getDefaultRequestProperties(Object resource)
          Returns default request properties
 ResponseProperty[] getDefaultResponseProperties(Object resource)
          Returns default response properties
 File getFilePath()
          Returns root file path
 InputStream getInpusStream(Object resource, long from, long length)
          Returns RandomAccessFileRangeInputStream
 InputStream getInputStream(Object resource)
          Returns FileInputStream
 LockingMechanism getLockingMechanism()
          Returns locking mechanism
 NamespacesProvider getNamespacesProvider()
          Returns namespace provider
 OutputStream getOutputStream(Object resource)
          Returns FileOutputStream
 OutputStream getOutputStream(Object resource, long from, long length)
          Returns RandomAccessFileRangeOutputStream
 String getResourceETag(Object resource)
          Returns file's last modified timestamp as hex plus file's absolute path
 String getResourceName(Object resource)
          Returns file's name
protected  void initHandlers()
          Initialises handlers
 boolean isCollection(Object resource)
          Returns true if file is a directory
 void makeCollection(Object resource)
          Makes a directory
 void move(Object source, Object destination)
          Renames the file
 long resourceCreated(Object resource)
          Returns file's last modified timestamp
 long resourceLastModified(Object resource)
          Returns file's last modified timestamp
 long resourceLength(Object resource)
          Returns file's length
 void setFilePath(File path)
          Sets root file path
 void setLockingMechanism(LockingMechanism lockingMechanism)
          Sets locking mechanism
 void setNamespacesProvider(NamespacesProvider namespacesProvider)
          Sets namespace provider
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

path

protected File path
Root path of the files to be served


filePropertyNames

protected static ResponseProperty[] filePropertyNames
Default file property names


dirPropertyNames

protected static ResponseProperty[] dirPropertyNames
Default directory property names


fileRequestProperties

protected static RequestProperty[] fileRequestProperties
Default file request properties


dirRequestProperties

protected static RequestProperty[] dirRequestProperties
Default dir request properties


namespacesProvider

protected NamespacesProvider namespacesProvider
Namespace provider to be used with this adapter


lockingMechanism

protected LockingMechanism lockingMechanism
Locking mechanism to be used with this adapter


davNamespace

protected DAVNamespace davNamespace
Default DAV namespace

Constructor Detail

FileSystemWebDAVResourceAdapter

public FileSystemWebDAVResourceAdapter()
Constructor


FileSystemWebDAVResourceAdapter

public FileSystemWebDAVResourceAdapter(File path)
Constructor

Parameters:
path - root directory for files to be served from
Method Detail

initHandlers

protected void initHandlers()
Initialises handlers


getFilePath

public File getFilePath()
Returns root file path

Returns:
root file path

setFilePath

public void setFilePath(File path)
Sets root file path

Parameters:
path - root file path

getNamespacesProvider

public NamespacesProvider getNamespacesProvider()
Returns namespace provider

Specified by:
getNamespacesProvider in interface ResourceAdapter
Returns:
namespace provider

setNamespacesProvider

public void setNamespacesProvider(NamespacesProvider namespacesProvider)
Sets namespace provider

Parameters:
namespacesProvider - namespace provider

getLockingMechanism

public LockingMechanism getLockingMechanism()
Returns locking mechanism

Specified by:
getLockingMechanism in interface ResourceAdapter
Returns:
locking mechanism

setLockingMechanism

public void setLockingMechanism(LockingMechanism lockingMechanism)
Sets locking mechanism

Parameters:
lockingMechanism - locking mechanism

collectionElements

public Object[] collectionElements(Object resource)
Returns File objects of supplied resource directory

Specified by:
collectionElements in interface ResourceAdapter
Parameters:
resource - resource
Returns:
File objects of supplied resource directory

copy

public void copy(Object source,
                 Object destination,
                 boolean recursive)
          throws IOException
Copies source file to destination file

Specified by:
copy in interface ResourceAdapter
Parameters:
source - source file
destination - destination file
recursive - is it deep copy
Throws:
IOException - thrown if there is a problem with copying.

delete

public void delete(Object resource)
            throws IOException
Deletes a file

Specified by:
delete in interface ResourceAdapter
Parameters:
resource - file
Throws:
IOException - thrown if there is a problem with deletion of the resource

exists

public boolean exists(Object resource)
Returns true if file exists

Specified by:
exists in interface ResourceAdapter
Parameters:
resource - resource
Returns:
true if file exists

findResource

public Object findResource(String path)
Returns File object of given path startin from path

Specified by:
findResource in interface ResourceAdapter
Parameters:
path - path
Returns:
a file

findParentResource

public Object findParentResource(Object resource)
Returns file's parent

Specified by:
findParentResource in interface ResourceAdapter
Parameters:
resource - file
Returns:
file's parent

getDefaultRequestProperties

public RequestProperty[] getDefaultRequestProperties(Object resource)
Returns default request properties

Specified by:
getDefaultRequestProperties in interface ResourceAdapter
Parameters:
resource - a file
Returns:
dirRequestProperties or fileRequestProperties

getDefaultResponseProperties

public ResponseProperty[] getDefaultResponseProperties(Object resource)
Returns default response properties

Specified by:
getDefaultResponseProperties in interface ResourceAdapter
Parameters:
resource - a file
Returns:
dirPropertyNames or filePropertyNames

getInputStream

public InputStream getInputStream(Object resource)
Returns FileInputStream

Specified by:
getInputStream in interface ResourceAdapter
Parameters:
resource - a file
Returns:
FileInputStream

getInpusStream

public InputStream getInpusStream(Object resource,
                                  long from,
                                  long length)
Returns RandomAccessFileRangeInputStream

Specified by:
getInpusStream in interface ResourceAdapter
Parameters:
resource - a file
from - from offset
length - length in bytes
Returns:
RandomAccessFileRangeInputStream

getOutputStream

public OutputStream getOutputStream(Object resource)
Returns FileOutputStream

Specified by:
getOutputStream in interface ResourceAdapter
Parameters:
resource - a file
Returns:
FileOutputStream

getOutputStream

public OutputStream getOutputStream(Object resource,
                                    long from,
                                    long length)
Returns RandomAccessFileRangeOutputStream

Specified by:
getOutputStream in interface ResourceAdapter
Parameters:
resource - a file
from - from offset
length - length in bytes
Returns:
RandomAccessFileRangeOutputStream

getResourceName

public String getResourceName(Object resource)
Returns file's name

Specified by:
getResourceName in interface ResourceAdapter
Parameters:
resource - file
Returns:
file's name

getResourceETag

public String getResourceETag(Object resource)
Returns file's last modified timestamp as hex plus file's absolute path

Specified by:
getResourceETag in interface ResourceAdapter
Parameters:
resource - file
Returns:
file's last modified timestamp as hex plus file's absolute path

isCollection

public boolean isCollection(Object resource)
Returns true if file is a directory

Specified by:
isCollection in interface ResourceAdapter
Parameters:
resource - a file
Returns:
true if file is a directory

makeCollection

public void makeCollection(Object resource)
                    throws IOException
Makes a directory

Specified by:
makeCollection in interface ResourceAdapter
Parameters:
resource - a file
Throws:
IOException - thrown in there is a problem in making the file

move

public void move(Object source,
                 Object destination)
          throws IOException
Renames the file

Specified by:
move in interface ResourceAdapter
Parameters:
source - source
destination - destination
Throws:
IOException - thrown if there is a problem with copying the file

resourceCreated

public long resourceCreated(Object resource)
Returns file's last modified timestamp

Specified by:
resourceCreated in interface ResourceAdapter
Parameters:
resource - a file
Returns:
file's last modified timestamp

resourceLastModified

public long resourceLastModified(Object resource)
Returns file's last modified timestamp

Specified by:
resourceLastModified in interface ResourceAdapter
Parameters:
resource - a file
Returns:
file's last modified timestamp

resourceLength

public long resourceLength(Object resource)
Returns file's length

Specified by:
resourceLength in interface ResourceAdapter
Parameters:
resource - a file
Returns:
file's length


Copyright © 2005-2009 Abstract Horizon. All Rights Reserved.