pulse - the web application framework Get pulse at SourceForge.net. Fast, secure and Free Open Source software downloads Ohloh project report for pulse-java

org.torweg.pulse.vfs
Class VFSDAVStore

java.lang.Object
  extended by org.torweg.pulse.vfs.VFSDAVStore
All Implemented Interfaces:
DAVStore

public final class VFSDAVStore
extends java.lang.Object
implements DAVStore

a DAVStore implementation for the VirtualFileSystem .

Version:
$Revision: 1773 $
Author:
Thomas Weber

Constructor Summary
VFSDAVStore()
           
 
Method Summary
 boolean addDeadProperty(java.net.URI uri, User user, DeadProperty prop)
          sets a dead property for the object identified by the given URI.
 boolean addDeadProperty(VirtualFile file, User user, DeadProperty prop)
          sets a dead property for the given VirtualFile.
 boolean canRead(java.net.URI uri, User user)
          checks whether the given User can read the VirtualFile identified by the given URI.
 boolean canWrite(java.net.URI uri, User user)
          checks whether the given User can read the VirtualFile identified by the given URI.
 void copy(java.net.URI sourceURI, java.net.URI destinationURI, User user, MultiStatusResponse response)
          performs a recursive copy command.
 boolean createResourceCollection(java.net.URI uri, User user)
          creates a new resource collection at the specified URI.
 java.net.URI enforceTailingSlash(java.net.URI uri)
          enforces a tailing slash (needed for collection URIs).
 java.lang.String getCharacterEncoding(java.net.URI uri, User user)
          returns the character encoding of the URI or null, if the encoding is unknown.
 java.util.Collection<java.net.URI> getChildren(java.net.URI uri, User user)
          returns the children of the given URI which are readable for the given user.
 java.io.InputStream getContent(java.net.URI uri, User user)
          returns an InputStream for the given URI, if the given user is allow to read the resource.
 long getContentLength(java.net.URI uri, User user)
          returns the length of the resource.
 java.lang.String getContentType(java.net.URI uri, User user)
          returns the content-type of the URI.
 long getCreationDate(java.net.URI uri, User user)
          returns the creation-date of the URI.
 org.jdom.Content getDAVProperty(java.net.URI uri, User user, DAVProperties prop)
          returns the requested property for the given URI provided the user has read access.
 org.jdom.Content getDAVProperty(VirtualFile file, User user, DAVProperties prop)
          returns the requested property for the given VirtualFile provided the user has read access.
 java.util.Collection<DeadProperty> getDeadProperties()
          returns a collection of all dead property types known to the server.
 java.util.Collection<DeadProperty> getDeadProperties(java.net.URI uri)
          returns a collection of all dead properties of the given URI.
 java.util.Collection<DeadProperty> getDeadProperties(VirtualFile file)
          returns a collection of all dead properties of the given file.
 DeadProperty getDeadProperty(java.net.URI uri, User user, DeadProperty prop)
          returns the requested dead property for the given URI provided the User has read access.
 DeadProperty getDeadProperty(VirtualFile file, User user, DeadProperty prop)
          returns the requested dead property for the given VirtualFile provided the User has read access.
 java.lang.String getETag(java.net.URI uri)
          returns an ETag for the VirtualFile identified by the given URI.
 long getLastModified(java.net.URI uri, User user)
          returns the last modification date of the URI.
 java.net.URI getParentURI(java.net.URI resourceURI)
          returns the URI of the parent or the URI itself, if it denotes the root.
 boolean isCollection(java.net.URI uri)
          returns true, if the given URI points to a collection.
 boolean isResource(java.net.URI uri)
          returns true, if the given URI points to a resource.
 void move(java.net.URI sourceURI, java.net.URI destinationURI, User user, MultiStatusResponse response)
          performs a recursive move command.
 boolean objectExists(java.net.URI uri)
          returns true, if the given URI points to an existing object.
 void removeObject(java.net.URI uri, User user)
          removes a single object.
 void setContent(java.net.URI uri, User user, java.io.InputStream content, java.lang.String contentType, java.lang.String characterEncoding, HttpDAVServletResponse res)
          sets the content of a resource and optionally creates it, if it does not exist yet.
 java.net.URI translateDavURI(java.lang.String uri)
          translates a WebDAV URI string to a VirtualFileSystem URI.
 java.net.URI translateStoreURI(java.net.URI uri)
          translates a store URI to a DAV URI.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

VFSDAVStore

public VFSDAVStore()
Method Detail

enforceTailingSlash

public java.net.URI enforceTailingSlash(java.net.URI uri)
enforces a tailing slash (needed for collection URIs).

Specified by:
enforceTailingSlash in interface DAVStore
Parameters:
uri - the URI
Returns:
the URI with a guaranteed slash at the end

translateDavURI

public java.net.URI translateDavURI(java.lang.String uri)
translates a WebDAV URI string to a VirtualFileSystem URI.

Specified by:
translateDavURI in interface DAVStore
Parameters:
uri - the WebDAV URI to convert
Returns:
the translated VirtualFileSystem URI

translateStoreURI

public java.net.URI translateStoreURI(java.net.URI uri)
translates a store URI to a DAV URI.

Specified by:
translateStoreURI in interface DAVStore
Parameters:
uri - the store URI.
Returns:
the DAV URI
See Also:
DAVStore.translateStoreURI(URI)

getParentURI

public java.net.URI getParentURI(java.net.URI resourceURI)
returns the URI of the parent or the URI itself, if it denotes the root.

Specified by:
getParentURI in interface DAVStore
Parameters:
resourceURI - the URI
Returns:
the parent

createResourceCollection

public boolean createResourceCollection(java.net.URI uri, User user)
creates a new resource collection at the specified URI.

Specified by:
createResourceCollection in interface DAVStore
Parameters:
uri - the URI of the new collection
user - the user
Returns:
true, if and only if the collection has been successfully created. Otherwise false.
See Also:
DAVStore.createResourceCollection(java.net.URI, org.torweg.pulse.accesscontrol.User)

getCharacterEncoding

public java.lang.String getCharacterEncoding(java.net.URI uri, User user)
returns the character encoding of the URI or null, if the encoding is unknown.

Specified by:
getCharacterEncoding in interface DAVStore
Parameters:
uri - the URI
user - the user
Returns:
the character encoding of the URI or null, if the encoding is unknown.
See Also:
DAVStore.getCharacterEncoding(java.net.URI, org.torweg.pulse.accesscontrol.User)

getChildren

public java.util.Collection<java.net.URI> getChildren(java.net.URI uri, User user)
returns the children of the given URI which are readable for the given user.

Specified by:
getChildren in interface DAVStore
Parameters:
uri - the URI
user - the user
Returns:
the children of the given URI which are readable for the given user
See Also:
DAVStore.getChildren(java.net.URI, org.torweg.pulse.accesscontrol.User)

getContent

public java.io.InputStream getContent(java.net.URI uri, User user)
                               throws java.io.IOException
returns an InputStream for the given URI, if the given user is allow to read the resource.

Specified by:
getContent in interface DAVStore
Parameters:
uri - the URI
user - the user
Returns:
an InputStream for the given URI or null, if the user is not allowed to read the resource
Throws:
java.io.IOException - on errors
See Also:
DAVStore.getContent(java.net.URI, org.torweg.pulse.accesscontrol.User)

getContentLength

public long getContentLength(java.net.URI uri, User user)
returns the length of the resource.

Specified by:
getContentLength in interface DAVStore
Parameters:
uri - the URI
user - the user
Returns:
the length of the resource or 0 (zero), if the user is not allowed to read the object
See Also:
DAVStore.getContentLength(java.net.URI, org.torweg.pulse.accesscontrol.User)

getContentType

public java.lang.String getContentType(java.net.URI uri, User user)
returns the content-type of the URI.

Specified by:
getContentType in interface DAVStore
Parameters:
uri - the URI
user - the user
Returns:
the content-type of the URI
See Also:
DAVStore.getContentType(java.net.URI, org.torweg.pulse.accesscontrol.User)

getCreationDate

public long getCreationDate(java.net.URI uri, User user)
returns the creation-date of the URI.

Specified by:
getCreationDate in interface DAVStore
Parameters:
uri - the URI
user - the user
Returns:
the creation-date
See Also:
DAVStore.getCreationDate(java.net.URI, org.torweg.pulse.accesscontrol.User)

getLastModified

public long getLastModified(java.net.URI uri, User user)
returns the last modification date of the URI.

Specified by:
getLastModified in interface DAVStore
Parameters:
uri - the URI
user - the user
Returns:
the last modification date
See Also:
DAVStore.getLastModified(java.net.URI, org.torweg.pulse.accesscontrol.User)

getDAVProperty

public org.jdom.Content getDAVProperty(java.net.URI uri, User user, DAVProperties prop)
                                throws java.io.IOException
returns the requested property for the given URI provided the user has read access.

Specified by:
getDAVProperty in interface DAVStore
Parameters:
uri - the uri
user - the user
prop - the property
Returns:
the requested property
Throws:
java.io.IOException - on errors retrieving the property
See Also:
DAVStore.getDAVProperty(java.net.URI, org.torweg.pulse.accesscontrol.User, org.torweg.pulse.webdav.util.DAVProperties)

getDAVProperty

public org.jdom.Content getDAVProperty(VirtualFile file, User user, DAVProperties prop)
returns the requested property for the given VirtualFile provided the user has read access.

Parameters:
file - the virtual file
user - the user
prop - the property
Returns:
the requested property

addDeadProperty

public boolean addDeadProperty(java.net.URI uri, User user, DeadProperty prop)
                        throws java.io.IOException
sets a dead property for the object identified by the given URI.

Specified by:
addDeadProperty in interface DAVStore
Parameters:
uri - the URI
user - the user
prop - the property to set
Returns:
true, if and only if the property has been set. Otherwise false.
Throws:
java.io.IOException - on errors accessing the VirtualFile identified by the given URI
See Also:
DAVStore.addDeadProperty(URI, User, DeadProperty)

addDeadProperty

public boolean addDeadProperty(VirtualFile file, User user, DeadProperty prop)
                        throws java.io.IOException
sets a dead property for the given VirtualFile.

Parameters:
file - the virtual files
user - the user
prop - the property to set
Returns:
true, if and only if the property has been set. Otherwise false.
Throws:
java.io.IOException - on errors accessing the object
See Also:
DAVStore.addDeadProperty(URI, User, DeadProperty)

getDeadProperty

public DeadProperty getDeadProperty(java.net.URI uri, User user, DeadProperty prop)
                             throws java.io.IOException
returns the requested dead property for the given URI provided the User has read access.

Specified by:
getDeadProperty in interface DAVStore
Parameters:
uri - the uri
user - the user
prop - the property
Returns:
the requested property
Throws:
java.io.IOException - on errors accessing the VirtualFile identified by the given URI
See Also:
DAVStore.getDeadProperty(URI, User, DeadProperty)

getDeadProperty

public DeadProperty getDeadProperty(VirtualFile file, User user, DeadProperty prop)
returns the requested dead property for the given VirtualFile provided the User has read access.

Parameters:
file - the virtual file
user - the user
prop - the property
Returns:
the requested property
See Also:
DAVStore.getDeadProperty(URI, User, DeadProperty)

getDeadProperties

public java.util.Collection<DeadProperty> getDeadProperties()
returns a collection of all dead property types known to the server.

Specified by:
getDeadProperties in interface DAVStore
Returns:
a collection of all dead property types
See Also:
DAVStore.getDeadProperties()

getDeadProperties

public java.util.Collection<DeadProperty> getDeadProperties(java.net.URI uri)
returns a collection of all dead properties of the given URI.

Specified by:
getDeadProperties in interface DAVStore
Parameters:
uri - the URI
Returns:
a collection of all dead property types
See Also:
DAVStore.getDeadProperties()

getDeadProperties

public java.util.Collection<DeadProperty> getDeadProperties(VirtualFile file)
returns a collection of all dead properties of the given file.

Parameters:
file - the virtual file
Returns:
a collection of all dead property types
See Also:
DAVStore.getDeadProperties()

isCollection

public boolean isCollection(java.net.URI uri)
returns true, if the given URI points to a collection.

Specified by:
isCollection in interface DAVStore
Parameters:
uri - the uri
Returns:
true, if the given URI points to a collection
See Also:
DAVStore.isCollection(java.net.URI)

isResource

public boolean isResource(java.net.URI uri)
returns true, if the given URI points to a resource.

Specified by:
isResource in interface DAVStore
Parameters:
uri - the uri
Returns:
true, if the given URI points to a resource
See Also:
DAVStore.isResource(java.net.URI)

objectExists

public boolean objectExists(java.net.URI uri)
returns true, if the given URI points to an existing object.

Specified by:
objectExists in interface DAVStore
Parameters:
uri - the uri
Returns:
true, if the given URI points to an existing object
See Also:
DAVStore.objectExists(java.net.URI)

setContent

public void setContent(java.net.URI uri, User user,
                       java.io.InputStream content,
                       java.lang.String contentType,
                       java.lang.String characterEncoding, HttpDAVServletResponse res)
                throws java.io.IOException
sets the content of a resource and optionally creates it, if it does not exist yet.

Specified by:
setContent in interface DAVStore
Parameters:
uri - the URI
user - the user
content - the input stream
contentType - the content type specified by the client
characterEncoding - the character encoding specified by the client
res - the response
Throws:
java.io.IOException - on errors setting the content

getETag

public java.lang.String getETag(java.net.URI uri)
returns an ETag for the VirtualFile identified by the given URI.

Specified by:
getETag in interface DAVStore
Parameters:
uri - the URI
Returns:
the ETag

canRead

public boolean canRead(java.net.URI uri, User user)
checks whether the given User can read the VirtualFile identified by the given URI.

Specified by:
canRead in interface DAVStore
Parameters:
uri - the URI
user - the user
Returns:
true, if and only if the user has read access. Otherwise false.

canWrite

public boolean canWrite(java.net.URI uri, User user)
checks whether the given User can read the VirtualFile identified by the given URI.

Specified by:
canWrite in interface DAVStore
Parameters:
uri - the uri
user - the user
Returns:
true, if and only if the user has read access. Otherwise false.

removeObject

public void removeObject(java.net.URI uri, User user)
                  throws java.io.IOException
removes a single object.

Specified by:
removeObject in interface DAVStore
Parameters:
uri - the URI
user - the user
Throws:
java.io.IOException - on errors removing the object
See Also:
DAVStore.removeObject(java.net.URI, org.torweg.pulse.accesscontrol.User)

copy

public void copy(java.net.URI sourceURI,
                 java.net.URI destinationURI, User user, MultiStatusResponse response)
          throws java.io.IOException
performs a recursive copy command.

Specified by:
copy in interface DAVStore
Parameters:
sourceURI - the source URI
destinationURI - the destination URI
user - the user
response - the multi-status response
Throws:
java.io.IOException - on errors
See Also:
DAVStore.copy(URI, URI, User, MultiStatusResponse)

move

public void move(java.net.URI sourceURI,
                 java.net.URI destinationURI, User user, MultiStatusResponse response)
          throws java.io.IOException
performs a recursive move command.

Specified by:
move in interface DAVStore
Parameters:
sourceURI - the source URI
destinationURI - the destination URI
user - the user
response - the multi-status response
Throws:
java.io.IOException - on errors
See Also:
DAVStore.move(URI, URI, User, MultiStatusResponse)