Package org.drjekyll.webdav.store
Class LocalFileSystemStore
- java.lang.Object
-
- org.drjekyll.webdav.store.LocalFileSystemStore
-
- All Implemented Interfaces:
WebdavStore
public class LocalFileSystemStore extends Object implements WebdavStore
Reference Implementation of WebdavStore- Author:
- joa, re
-
-
Constructor Summary
Constructors Constructor Description LocalFileSystemStore(File root)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description Transaction
begin(Principal principal)
Indicates that a new request or transaction with this store involved has been started.void
checkAuthentication(Transaction transaction)
Checks if authentication information passed in is valid.void
commit(Transaction transaction)
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(Transaction transaction, String uri)
Creates a folder at the position specified byfolderUri
.void
createResource(Transaction transaction, String uri)
Creates a content resource at the position specified byresourceUri
.void
destroy()
Life cycle method, called by WebdavServlet's destroy() method.String[]
getChildrenNames(Transaction transaction, String uri)
Gets the names of the children of the folder specified byfolderUri
.InputStream
getResourceContent(Transaction transaction, String uri)
Gets the content of the resource specified byresourceUri
.long
getResourceLength(Transaction transaction, String uri)
Gets the length of the content resource specified byresourceUri
.StoredObject
getStoredObject(Transaction transaction, String uri)
Gets the storedObject specified byuri
void
removeObject(Transaction transaction, String uri)
Removes the object specified byuri
.void
rollback(Transaction transaction)
Indicates that all changes done inside this request shall be undone and any transactions, connections and other temporary resources shall be terminated.long
setResourceContent(Transaction transaction, String uri, InputStream is, String contentType, String characterEncoding)
Sets / stores the content of the resource specified byresourceUri
.
-
-
-
Constructor Detail
-
LocalFileSystemStore
public LocalFileSystemStore(File root)
-
-
Method Detail
-
destroy
public void destroy()
Description copied from interface:WebdavStore
Life cycle method, called by WebdavServlet's destroy() method. Should be used to clean up resources.- Specified by:
destroy
in interfaceWebdavStore
-
begin
@Nullable public Transaction begin(Principal principal)
Description copied from interface:WebdavStore
Indicates that a new request or transaction with this store involved has been started. The request will be terminated by eitherWebdavStore.commit(org.drjekyll.webdav.Transaction)
orWebdavStore.rollback(org.drjekyll.webdav.Transaction)
. If only non-read methods have been called, the request will be terminated by aWebdavStore.commit(org.drjekyll.webdav.Transaction)
. This method will be called by (@link WebdavStoreAdapter} at the beginning of each request.- Specified by:
begin
in interfaceWebdavStore
- Parameters:
principal
- the principal that started this request ornull
if there is non available
-
checkAuthentication
public void checkAuthentication(Transaction transaction)
Description copied from interface:WebdavStore
Checks if authentication information passed in is valid. If not throws an exception.- Specified by:
checkAuthentication
in interfaceWebdavStore
- Parameters:
transaction
- indicates that the method is within the scope of a WebDAV transaction
-
commit
public void commit(Transaction transaction)
Description copied from interface:WebdavStore
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 interfaceWebdavStore
- Parameters:
transaction
- indicates that the method is within the scope of a WebDAV transaction
-
rollback
public void rollback(Transaction transaction)
Description copied from interface:WebdavStore
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 interfaceWebdavStore
- Parameters:
transaction
- indicates that the method is within the scope of a WebDAV transaction
-
createFolder
public void createFolder(Transaction transaction, String uri)
Description copied from interface:WebdavStore
Creates a folder at the position specified byfolderUri
.- Specified by:
createFolder
in interfaceWebdavStore
- Parameters:
transaction
- indicates that the method is within the scope of a WebDAV transactionuri
- URI of the folder
-
createResource
public void createResource(Transaction transaction, String uri)
Description copied from interface:WebdavStore
Creates a content resource at the position specified byresourceUri
.- Specified by:
createResource
in interfaceWebdavStore
- Parameters:
transaction
- indicates that the method is within the scope of a WebDAV transactionuri
- URI of the content resource
-
getResourceContent
public InputStream getResourceContent(Transaction transaction, String uri)
Description copied from interface:WebdavStore
Gets the content of the resource specified byresourceUri
.- Specified by:
getResourceContent
in interfaceWebdavStore
- Parameters:
transaction
- indicates that the method is within the scope of a WebDAV transactionuri
- URI of the content resource- Returns:
- input stream you can read the content of the resource from
-
setResourceContent
public long setResourceContent(Transaction transaction, String uri, InputStream is, String contentType, String characterEncoding)
Description copied from interface:WebdavStore
Sets / stores the content of the resource specified byresourceUri
.- Specified by:
setResourceContent
in interfaceWebdavStore
- Parameters:
transaction
- indicates that the method is within the scope of a WebDAV transactionuri
- URI of the resource where the content will be storedis
- input stream from which the content will be read fromcontentType
- content type of the resource ornull
if unknowncharacterEncoding
- character encoding of the resource ornull
if unknown or not applicable- Returns:
- lenght of resource
-
getChildrenNames
public String[] getChildrenNames(Transaction transaction, String uri)
Description copied from interface:WebdavStore
Gets the names of the children of the folder specified byfolderUri
.- Specified by:
getChildrenNames
in interfaceWebdavStore
- Parameters:
transaction
- indicates that the method is within the scope of a WebDAV transactionuri
- URI of the folder- Returns:
- a (possibly empty) list of children, or
null
if the uri points to a file
-
removeObject
public void removeObject(Transaction transaction, String uri)
Description copied from interface:WebdavStore
Removes the object specified byuri
.- Specified by:
removeObject
in interfaceWebdavStore
- Parameters:
transaction
- indicates that the method is within the scope of a WebDAV transactionuri
- URI of the object, i.e. content resource or folder
-
getResourceLength
public long getResourceLength(Transaction transaction, String uri)
Description copied from interface:WebdavStore
Gets the length of the content resource specified byresourceUri
.- Specified by:
getResourceLength
in interfaceWebdavStore
- Parameters:
transaction
- indicates that the method is within the scope of a WebDAV transactionuri
- URI of the content resource- Returns:
- length of the resource in bytes,
-1
declares this value as invalid and asks the adapter to try to set it from the properties if possible
-
getStoredObject
public StoredObject getStoredObject(Transaction transaction, String uri)
Description copied from interface:WebdavStore
Gets the storedObject specified byuri
- Specified by:
getStoredObject
in interfaceWebdavStore
- Parameters:
transaction
- indicates that the method is within the scope of a WebDAV transactionuri
- URI- Returns:
- StoredObject
-
-