org.abstracthorizon.danube.webdav.java
Class JavaWebDAVResourceAdapter

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

public class JavaWebDAVResourceAdapter
extends Object
implements ResourceAdapter

Main class in reflection java resource adapter. This resource adapter allows WebDAV to be used in accessing internals of java objects. It exposes collections, maps, array, spring framework application contexts, java bean properties and methods to the WebDAV handler.

Author:
Daniel Sendula

Field Summary
protected  DAVNamespace davNamespace
          DAV namespace.
protected static ResponseProperty[] dirPropertyNames
          Available property names for 'dirs'
protected static RequestProperty[] dirRequestProperties
          Dir request properties
protected static ResponseProperty[] filePropertyNames
          Available property names for files
protected static RequestProperty[] fileRequestProperties
          File request propertyes
protected  LockingMechanism lockingMechanism
          Locking mechanism.
protected  NamespacesProvider namespacesProvider
          Namespace provider.
protected  Object rootObject
          Root object
 
Constructor Summary
JavaWebDAVResourceAdapter()
          Constructor
JavaWebDAVResourceAdapter(Object rootObject)
          Constructor
 
Method Summary
 Object[] collectionElements(Object resource)
          Returns null if resource is delegate.
 void copy(Object source, Object destination, boolean recursive)
          Not implemented
 void delete(Object resource)
          Not implemented
 boolean exists(Object resource)
          Returns if resource exists.
protected  Object findObjectImpl(Bean bean)
          This method returns real object from the given bean
protected  Object findObjectImpl(String resourcePath)
          This method returns real object from the given path
 Object findParentResource(Object resource)
          Returns parent resource of the given resource.
 Object findResource(String resourcePath)
          Finds a resource (object) from the given path.
 String getContentType(Object resource)
          Returns content type.
 RequestProperty[] getDefaultRequestProperties(Object resource)
           
 ResponseProperty[] getDefaultResponseProperties(Object resource)
           
 InputStream getInpusStream(Object resource, long from, long length)
          Returns input stream.
 InputStream getInputStream(Object resource)
          Returns input stream.
 LockingMechanism getLockingMechanism()
          Returns locking mechanism
 NamespacesProvider getNamespacesProvider()
          Returns namespace provider
 OutputStream getOutputStream(Object resource)
          Returns output stream.
 OutputStream getOutputStream(Object resource, long from, long length)
          Returns output stream.
 String getResourceETag(Object resource)
          Returns etag.
 String getResourceName(Object resource)
          Returns resource name from the last portion of the path
 Object getRootObject()
          Returns root object
protected  void initHandlers()
          Initialises java dav facotry and sets namespace
 boolean isCollection(Object resource)
          Returns if resource is collection.
 void makeCollection(Object resource)
          Not implemented
 void move(Object source, Object destination)
          Not implemented
 long resourceCreated(Object resource)
          Returns -1
 long resourceLastModified(Object resource)
          Returns -1
 long resourceLength(Object resource)
          Returns resource length.
 void setLockingMechanism(LockingMechanism lockingMechanism)
          Sets locking mechanism
 void setNamespacesProvider(NamespacesProvider namespacesProvider)
          Sets namespace provider
 void setRootObject(Object root)
          Sets root object
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

rootObject

protected Object rootObject
Root object


filePropertyNames

protected static ResponseProperty[] filePropertyNames
Available property names for files


dirPropertyNames

protected static ResponseProperty[] dirPropertyNames
Available property names for 'dirs'


fileRequestProperties

protected static RequestProperty[] fileRequestProperties
File request propertyes


dirRequestProperties

protected static RequestProperty[] dirRequestProperties
Dir request properties


namespacesProvider

protected NamespacesProvider namespacesProvider
Namespace provider. It defaults to SimpleNamespacesProvider.


lockingMechanism

protected LockingMechanism lockingMechanism
Locking mechanism. It defaults to SimpleInMemoryLockingMechanism.


davNamespace

protected DAVNamespace davNamespace
DAV namespace. It defaults to DAVNamespace

Constructor Detail

JavaWebDAVResourceAdapter

public JavaWebDAVResourceAdapter()
Constructor


JavaWebDAVResourceAdapter

public JavaWebDAVResourceAdapter(Object rootObject)
Constructor

Parameters:
rootObject - root object
Method Detail

initHandlers

protected void initHandlers()
Initialises java dav facotry and sets namespace


getRootObject

public Object getRootObject()
Returns root object

Returns:
root object

setRootObject

public void setRootObject(Object root)
Sets root object

Parameters:
root - root object

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

findResource

public Object findResource(String resourcePath)
Finds a resource (object) from the given path. It returns Bean or extension of that object

Specified by:
findResource in interface ResourceAdapter
Parameters:
resourcePath - path to the resource
Returns:
a resource

findObjectImpl

protected Object findObjectImpl(Bean bean)
This method returns real object from the given bean

Parameters:
bean - bean (defines path)
Returns:
an object or null if failed

findObjectImpl

protected Object findObjectImpl(String resourcePath)
This method returns real object from the given path

Parameters:
path - path
Returns:
an object or null if failed

findParentResource

public Object findParentResource(Object resource)
Returns parent resource of the given resource. It takes the path and finds parent of the path and then creates new bean object (or extension) and returns that. If object is already root objec then it returns null

Specified by:
findParentResource in interface ResourceAdapter
Parameters:
resource - existing resource
Returns:
parent resource

resourceLength

public long resourceLength(Object resource)
Returns resource length. It consults Delegate if resource is of that type.

Specified by:
resourceLength in interface ResourceAdapter
Parameters:
resource - resource
Returns:
resource length

resourceLastModified

public long resourceLastModified(Object resource)
Returns -1

Specified by:
resourceLastModified in interface ResourceAdapter
Parameters:
resource - resource
Returns:
-1

resourceCreated

public long resourceCreated(Object resource)
Returns -1

Specified by:
resourceCreated in interface ResourceAdapter
Parameters:
resource - resource
Returns:
-1

getResourceName

public String getResourceName(Object resource)
Returns resource name from the last portion of the path

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

getResourceETag

public String getResourceETag(Object resource)
Returns etag. It consults Delegate if resource is of that type.

Specified by:
getResourceETag in interface ResourceAdapter
Parameters:
resource - resource
Returns:
etag

exists

public boolean exists(Object resource)
Returns if resource exists.

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

isCollection

public boolean isCollection(Object resource)
Returns if resource is collection. It consults Delegate if resource is of that type.

Specified by:
isCollection in interface ResourceAdapter
Parameters:
resource - resource
Returns:
true if resource is collection

delete

public void delete(Object resource)
            throws IOException
Not implemented

Specified by:
delete in interface ResourceAdapter
Parameters:
resource - resource
Throws:
IOException - if there were errors while deleting the resource

makeCollection

public void makeCollection(Object resource)
                    throws IOException
Not implemented

Specified by:
makeCollection in interface ResourceAdapter
Parameters:
resource - resource
Throws:
IOException - if there were errors while collection is created

copy

public void copy(Object source,
                 Object destination,
                 boolean recursive)
          throws IOException
Not implemented

Specified by:
copy in interface ResourceAdapter
Parameters:
source - source
destination - destination
recursive - deep copy
Throws:
IOException - if there were errors while copying resource(s)

move

public void move(Object source,
                 Object destination)
          throws IOException
Not implemented

Specified by:
move in interface ResourceAdapter
Parameters:
source - source
destination - destination
Throws:
IOException - if there were errors while moving resource(s)

collectionElements

public Object[] collectionElements(Object resource)
Returns null if resource is delegate. Otherwise returns list of collection, map, arrays, properties, methods, etc..

Specified by:
collectionElements in interface ResourceAdapter
Parameters:
resource - resource
Returns:
object

getDefaultRequestProperties

public RequestProperty[] getDefaultRequestProperties(Object resource)
Specified by:
getDefaultRequestProperties in interface ResourceAdapter

getDefaultResponseProperties

public ResponseProperty[] getDefaultResponseProperties(Object resource)
Specified by:
getDefaultResponseProperties in interface ResourceAdapter

getInputStream

public InputStream getInputStream(Object resource)
Returns input stream. It consults Delegate if resource is of that type.

Specified by:
getInputStream in interface ResourceAdapter
Parameters:
resource - resource
Returns:
input stream or null

getInpusStream

public InputStream getInpusStream(Object resource,
                                  long from,
                                  long length)
Returns input stream. It consults Delegate if resource is of that type.

Specified by:
getInpusStream in interface ResourceAdapter
Parameters:
from - offset
length - length
resource - resource
Returns:
input stream or null

getOutputStream

public OutputStream getOutputStream(Object resource)
Returns output stream. It consults Delegate if resource is of that type.

Specified by:
getOutputStream in interface ResourceAdapter
Parameters:
resource - resource
Returns:
input stream or null

getOutputStream

public OutputStream getOutputStream(Object resource,
                                    long from,
                                    long length)
Returns output stream. It consults Delegate if resource is of that type.

Specified by:
getOutputStream in interface ResourceAdapter
Parameters:
from - offset
length - length
resource - resource
Returns:
output stream or null

getContentType

public String getContentType(Object resource)
Returns content type. It consults Delegate if resource is of that type.

Returns:
content type or "unknown/unknown"


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