edu.ucsb.nceas.morpho.framework
Class FileSystemDataStore

java.lang.Object
  |
  +--edu.ucsb.nceas.morpho.framework.DataStore
        |
        +--edu.ucsb.nceas.morpho.framework.FileSystemDataStore
All Implemented Interfaces:
DataStoreInterface

public class FileSystemDataStore
extends DataStore
implements DataStoreInterface

implements and the DataStoreInterface for accessing files on the local file system.


Fields inherited from class edu.ucsb.nceas.morpho.framework.DataStore
cachedir, datadir, separator, tempdir
 
Constructor Summary
FileSystemDataStore(ClientFramework cf)
          create a new FileSystemDataStore for a ClientFramework
 
Method Summary
 boolean deleteFile(java.lang.String name)
          deletes a file from the local file system.
static void main(java.lang.String[] args)
          Test method
 java.io.File newDataFile(java.lang.String name, java.io.InputStream is)
           
 java.io.File newFile(java.lang.String name, java.io.Reader file)
          returns a File object in the local repository.
 java.io.File newFile(java.lang.String name, java.io.Reader file, DataPackage dp)
          returns a File object in the local repository.
 java.io.File openFile(java.lang.String name)
          opens a file with the given name.
 java.io.File saveDataFile(java.lang.String name, java.io.InputStream file)
           
 java.io.File saveDataFile(java.lang.String name, java.io.InputStream file, java.lang.String rootDir, DataPackage dp)
          A variant of saveFile designed for use with Data Files.
 java.io.File saveDataFile(java.lang.String name, java.io.Reader file)
           
 java.io.File saveDataFile(java.lang.String name, java.io.Reader file, java.lang.String rootDir, DataPackage dp)
          A variant of saveFile designed for use with Data Files.
 java.io.File saveFile(java.lang.String name, java.io.Reader file)
           
 java.io.File saveFile(java.lang.String name, java.io.Reader file, DataPackage dp)
          save a file to the datastore with the id of name.
 java.io.File saveFile(java.lang.String name, java.io.Reader file, java.lang.String rootDir, DataPackage dp)
          Saves a file with the given name.
 java.io.File saveTempDataFile(java.lang.String name, java.io.InputStream file)
           
 java.io.File saveTempDataFile(java.lang.String name, java.io.Reader file)
           
 java.io.File saveTempFile(java.lang.String name, java.io.Reader file)
           
 
Methods inherited from class edu.ucsb.nceas.morpho.framework.DataStore
debug, insertIdInFile, parseId, parseIdFromMessage
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

FileSystemDataStore

public FileSystemDataStore(ClientFramework cf)
create a new FileSystemDataStore for a ClientFramework
Method Detail

openFile

public java.io.File openFile(java.lang.String name)
                      throws java.io.FileNotFoundException
opens a file with the given name. the name should be in the form scope.accnum where the scope is unique to this machine. The file will be opened from the <datadir>/<scope>/ directory where the filename is the accnum. Example: name=johnson2343.13223 datadir=data complete path=/usr/local/morpho/profiles/johnson/data/johnson2343/13223 Any characters after the first separator are assumed to be part of the accession number. Hence the id johnson2343.13223.5 would produce the file johnson2343/13223.5
Specified by:
openFile in interface DataStoreInterface
Overrides:
openFile in class DataStore

saveFile

public java.io.File saveFile(java.lang.String name,
                             java.io.Reader file)

saveFile

public java.io.File saveFile(java.lang.String name,
                             java.io.Reader file,
                             DataPackage dp)
Description copied from interface: DataStoreInterface
save a file to the datastore with the id of name. a file object representing the saved file is returned. If the publicAccess boolean is true, then an unauthenticated user may read the document from the data store.
Specified by:
saveFile in interface DataStoreInterface
Overrides:
saveFile in class DataStore

saveTempFile

public java.io.File saveTempFile(java.lang.String name,
                                 java.io.Reader file)

saveDataFile

public java.io.File saveDataFile(java.lang.String name,
                                 java.io.Reader file)

saveTempDataFile

public java.io.File saveTempDataFile(java.lang.String name,
                                     java.io.Reader file)

saveDataFile

public java.io.File saveDataFile(java.lang.String name,
                                 java.io.InputStream file)

saveTempDataFile

public java.io.File saveTempDataFile(java.lang.String name,
                                     java.io.InputStream file)

saveFile

public java.io.File saveFile(java.lang.String name,
                             java.io.Reader file,
                             java.lang.String rootDir,
                             DataPackage dp)
Saves a file with the given name. if the file does not exist it is created The file is saved according to the name provided. The file will be saved to the <datadir>/<scope>/ directory where the filename is the accnum. Example: name=johnson2343.13223 datadir=data complete path=/usr/local/morpho/profiles/johnson/data/johnson2343/13223 Any characters after the first separator are assumed to be part of the accession number. Hence the id johnson2343.13223.5 would produce the file johnson2343/13223.5

newFile

public java.io.File newFile(java.lang.String name,
                            java.io.Reader file,
                            DataPackage dp)
returns a File object in the local repository.
Specified by:
newFile in interface DataStoreInterface
Overrides:
newFile in class DataStore
Parameters:
name: - the id of the file
file: - the stream to the file
publicAccess: - flag for unauthenticated read access to the file. true if anauthenticated users can read the file, false otherwise.

newFile

public java.io.File newFile(java.lang.String name,
                            java.io.Reader file)
returns a File object in the local repository.
Parameters:
name: - the id of the file
file: - the stream to the file
publicAccess: - flag for unauthenticated read access to the file. true if anauthenticated users can read the file, false otherwise.

newDataFile

public java.io.File newDataFile(java.lang.String name,
                                java.io.InputStream is)

deleteFile

public boolean deleteFile(java.lang.String name)
deletes a file from the local file system. returns true if the file is successfully deleted, false otherwise.
Specified by:
deleteFile in interface DataStoreInterface
Overrides:
deleteFile in class DataStore
Parameters:
name - the name of the file to delete

main

public static void main(java.lang.String[] args)
Test method

saveDataFile

public java.io.File saveDataFile(java.lang.String name,
                                 java.io.Reader file,
                                 java.lang.String rootDir,
                                 DataPackage dp)
A variant of saveFile designed for use with Data Files. This avoids the writing of files to Strings that is in saveFile and allows for very large data files. (i.e. no file is put entirely in memory)

saveDataFile

public java.io.File saveDataFile(java.lang.String name,
                                 java.io.InputStream file,
                                 java.lang.String rootDir,
                                 DataPackage dp)
A variant of saveFile designed for use with Data Files. This avoids the writing of files to Strings that is in saveFile and allows for very large data files. (i.e. no file is put entirely in memory) This version uses an InputStream rather than a Reader to avoid problems with binary file corruption


Copyright © 2000 National Center for Ecological Analysis and Synthesis. All Rights Reserved.