nu.staldal.lagoon.core
Interface FileStorage

All Known Implementing Classes:
RemoteFileStorage

public interface FileStorage

Represent a FileStorage where generated files can be stored. File paths must be specified in UNIX style, i.e. with '/' used for separating directories. File paths must begin with a '/', they are all relative to the location set by the open() method. A FileStorage implementation must have a public no-arg constructor, to enable instantiation with Class.newInstance().


Method Summary
 void close()
          Close the file system and release any resources it holds.
 OutputHandler createFile(java.lang.String path)
          Create a new file, or overwrite an existing file.
 void deleteFile(java.lang.String path)
          Deletes a file.
 long fileLastModified(java.lang.String path)
          Check if a file exists and when it was last modified.
 boolean isReentrant()
          Ask if this file storage is reentrant.
 boolean needPassword()
          Ask if this file storage needs a password.
 void open(java.lang.String url, LagoonContext context, java.lang.String password)
          Open and initialize this file storage.
 

Method Detail

needPassword

boolean needPassword()
Ask if this file storage needs a password.


isReentrant

boolean isReentrant()
Ask if this file storage is reentrant.


open

void open(java.lang.String url,
          LagoonContext context,
          java.lang.String password)
          throws java.net.MalformedURLException,
                 java.io.IOException,
                 AuthenticationException
Open and initialize this file storage.

Parameters:
url - The URL to the file storage,
context - the LagoonContext.
password - the password nessesary to access this file storage, or null if no password is nessesary.
Throws:
AuthenticationException - if password was needed but incorrect.
java.net.MalformedURLException
java.io.IOException

close

void close()
           throws java.io.IOException
Close the file system and release any resources it holds. After this method has been invoked, no other method may be invoked.

Throws:
java.io.IOException

fileLastModified

long fileLastModified(java.lang.String path)
                      throws java.io.IOException
Check if a file exists and when it was last modified.

Parameters:
path - path to the file
Returns:
the time when the file was last modified, or -1 if that information is not avaliable or 0 if the file doesn't exists.
Throws:
java.io.IOException

createFile

OutputHandler createFile(java.lang.String path)
                         throws java.io.IOException
Create a new file, or overwrite an existing file.
  1. Invoke getOutputStream() on the returned OutputHandler
  2. Write to the OutputStream
  3. Do not close() the OutputStream
  4. Invoke commit() or discard() on the OutputHandler

Parameters:
path - path to the file
Returns:
an OutputHandler
Throws:
java.io.IOException

deleteFile

void deleteFile(java.lang.String path)
                throws java.io.IOException
Deletes a file. Does not signal any error if the file doesn't exist.

Parameters:
path - path to the file
Throws:
java.io.IOException