net.sf.webdav
Class LocalFileSystemStorage

java.lang.Object
  extended bynet.sf.webdav.LocalFileSystemStorage
All Implemented Interfaces:
IWebdavStorage

public class LocalFileSystemStorage
extends java.lang.Object
implements IWebdavStorage

Reference Implementation of IWebdavStorage

Author:
joa, re

Constructor Summary
LocalFileSystemStorage()
           
 
Method Summary
 void begin(java.security.Principal principal, java.util.Hashtable parameters)
          Indicates that a new request or transaction with this store involved has been started.
 void checkAuthentication()
          Checks if authentication information passed in #begin(Service, Principal, Object, LoggerFacade, Hashtable) is valid.
 void commit()
          Indicates that all changes done inside this request shall be made permanent and any transactions, connections and other temporary resources shall be terminated.
 void createFolder(java.lang.String uri)
          Creates a folder at the position specified by folderUri.
 void createResource(java.lang.String uri)
          Creates a content resource at the position specified by resourceUri.
 java.lang.String[] getChildrenNames(java.lang.String uri)
          Gets the names of the children of the folder specified by folderUri.
 java.util.Date getCreationDate(java.lang.String uri)
          Gets the date of the creation of the object specified by uri.
 java.util.Date getLastModified(java.lang.String uri)
          Gets the date of the last modiciation of the object specified by uri.
 java.io.InputStream getResourceContent(java.lang.String uri)
          Gets the content of the resource specified by resourceUri.
 long getResourceLength(java.lang.String uri)
          Gets the length of the content resource specified by resourceUri.
 boolean isFolder(java.lang.String uri)
          Checks if there is an object at the position specified by uri and if so if it is a folder.
 boolean isResource(java.lang.String uri)
          Checks if there is an object at the position specified by uri and if so if it is a content resource.
 boolean objectExists(java.lang.String uri)
          Checks if there is an object at the position specified by uri.
 void removeObject(java.lang.String uri)
          Removes the object specified by uri.
 void rollback()
          Indicates that all changes done inside this request shall be undone and any transactions, connections and other temporary resources shall be terminated.
 void setResourceContent(java.lang.String uri, java.io.InputStream is, java.lang.String contentType, java.lang.String characterEncoding)
          tries to save the given InputStream to the file at path "uri". content type and charachter encoding are ignored
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

LocalFileSystemStorage

public LocalFileSystemStorage()
Method Detail

begin

public void begin(java.security.Principal principal,
                  java.util.Hashtable parameters)
           throws java.lang.Exception
Description copied from interface: IWebdavStorage
Indicates that a new request or transaction with this store involved has been started. The request will be terminated by either IWebdavStorage.commit() or IWebdavStorage.rollback(). If only non-read methods have been called, the request will be terminated by a IWebdavStorage.commit(). This method will be called by (@link WebdavStoreAdapter} at the beginning of each request.

Specified by:
begin in interface IWebdavStorage
Parameters:
principal - the principal that started this request or null if there is non available
parameters - Hashtable containing the parameters' names and associated values configured in the from web.xml
Throws:
java.lang.Exception

checkAuthentication

public void checkAuthentication()
                         throws java.lang.SecurityException
Description copied from interface: IWebdavStorage
Checks if authentication information passed in #begin(Service, Principal, Object, LoggerFacade, Hashtable) is valid. If not throws an exception.

Specified by:
checkAuthentication in interface IWebdavStorage
Throws:
java.lang.SecurityException - if authentication is not valid

commit

public void commit()
            throws java.io.IOException
Description copied from interface: IWebdavStorage
Indicates that all changes done inside this request shall be made permanent and any transactions, connections and other temporary resources shall be terminated.

Specified by:
commit in interface IWebdavStorage
Throws:
java.io.IOException - if something goes wrong on the store level

rollback

public void rollback()
              throws java.io.IOException
Description copied from interface: IWebdavStorage
Indicates that all changes done inside this request shall be undone and any transactions, connections and other temporary resources shall be terminated.

Specified by:
rollback in interface IWebdavStorage
Throws:
java.io.IOException - if something goes wrong on the store level

objectExists

public boolean objectExists(java.lang.String uri)
                     throws java.io.IOException
Description copied from interface: IWebdavStorage
Checks if there is an object at the position specified by uri.

Specified by:
objectExists in interface IWebdavStorage
Parameters:
uri - URI of the object to check
Returns:
true if the object at uri exists
Throws:
java.io.IOException - if something goes wrong on the store level

isFolder

public boolean isFolder(java.lang.String uri)
                 throws java.io.IOException
Description copied from interface: IWebdavStorage
Checks if there is an object at the position specified by uri and if so if it is a folder.

Specified by:
isFolder in interface IWebdavStorage
Parameters:
uri - URI of the object to check
Returns:
true if the object at uri exists and is a folder
Throws:
java.io.IOException - if something goes wrong on the store level

isResource

public boolean isResource(java.lang.String uri)
                   throws java.io.IOException
Description copied from interface: IWebdavStorage
Checks if there is an object at the position specified by uri and if so if it is a content resource.

Specified by:
isResource in interface IWebdavStorage
Parameters:
uri - URI of the object to check
Returns:
true if the object at uri exists and is a content resource
Throws:
java.io.IOException - if something goes wrong on the store level

createFolder

public void createFolder(java.lang.String uri)
                  throws java.io.IOException
Description copied from interface: IWebdavStorage
Creates a folder at the position specified by folderUri.

Specified by:
createFolder in interface IWebdavStorage
Parameters:
uri - URI of the folder
Throws:
java.io.IOException - if the folder cannot be created

createResource

public void createResource(java.lang.String uri)
                    throws java.io.IOException
Description copied from interface: IWebdavStorage
Creates a content resource at the position specified by resourceUri.

Specified by:
createResource in interface IWebdavStorage
Parameters:
uri - URI of the content resource
Throws:
java.io.IOException - if the resource cannot be created

setResourceContent

public void setResourceContent(java.lang.String uri,
                               java.io.InputStream is,
                               java.lang.String contentType,
                               java.lang.String characterEncoding)
                        throws java.io.IOException
tries to save the given InputStream to the file at path "uri". content type and charachter encoding are ignored

Specified by:
setResourceContent in interface IWebdavStorage
Parameters:
uri - URI of the resource where the content will be stored
is - input stream from which the content will be read from
contentType - content type of the resource or null if unknown
characterEncoding - character encoding of the resource or null if unknown or not applicable
Throws:
java.io.IOException - if something goes wrong on the store level

getLastModified

public java.util.Date getLastModified(java.lang.String uri)
                               throws java.io.IOException
Description copied from interface: IWebdavStorage
Gets the date of the last modiciation of the object specified by uri.

Specified by:
getLastModified in interface IWebdavStorage
Parameters:
uri - URI of the object, i.e. content resource or folder
Returns:
the lastModified Date
Throws:
java.io.IOException - if something goes wrong on the store level

getCreationDate

public java.util.Date getCreationDate(java.lang.String uri)
                               throws java.io.IOException
Description copied from interface: IWebdavStorage
Gets the date of the creation of the object specified by uri.

Specified by:
getCreationDate in interface IWebdavStorage
Parameters:
uri - URI of the object, i.e. content resource or folder
Returns:
the lastModified date of the file, java.io.file does not support a creation date
Throws:
java.io.IOException - if something goes wrong on the store level

getChildrenNames

public java.lang.String[] getChildrenNames(java.lang.String uri)
                                    throws java.io.IOException
Description copied from interface: IWebdavStorage
Gets the names of the children of the folder specified by folderUri.

Specified by:
getChildrenNames in interface IWebdavStorage
Parameters:
uri - URI of the folder
Returns:
a (possibly empty) list of children, or null if the uri points to a file
Throws:
java.io.IOException - if something goes wrong on the store level

getResourceContent

public java.io.InputStream getResourceContent(java.lang.String uri)
                                       throws java.io.IOException
Description copied from interface: IWebdavStorage
Gets the content of the resource specified by resourceUri.

Specified by:
getResourceContent in interface IWebdavStorage
Parameters:
uri - URI of the content resource
Returns:
an input stream to the specified resource
Throws:
java.io.IOException - if something goes wrong on the store level

getResourceLength

public long getResourceLength(java.lang.String uri)
                       throws java.io.IOException
Description copied from interface: IWebdavStorage
Gets the length of the content resource specified by resourceUri.

Specified by:
getResourceLength in interface IWebdavStorage
Parameters:
uri - URI of the content resource
Returns:
the size of the file
Throws:
java.io.IOException - if something goes wrong on the store level

removeObject

public void removeObject(java.lang.String uri)
                  throws java.io.IOException
Description copied from interface: IWebdavStorage
Removes the object specified by uri.

Specified by:
removeObject in interface IWebdavStorage
Parameters:
uri - URI of the object, i.e. content resource or folder
Throws:
java.io.IOException - if the deletion failed


Copyright 2006-2006 media-style. All Rights Reserved.