org.nees.data.store.permanent
Class LocalFileStorage

java.lang.Object
  extended byorg.nees.data.store.permanent.LocalFileStorage
All Implemented Interfaces:
InstantiationContractInterface, PermanentStorageInterface

public class LocalFileStorage
extends java.lang.Object
implements PermanentStorageInterface

Author:
USER

Field Summary
static java.lang.String LOCAL_FILE_STORAGE_ROOT_KEY
           
 
Fields inherited from interface org.nees.data.store.permanent.PermanentStorageInterface
__CLASS_KEY, __IO_KEY
 
Constructor Summary
LocalFileStorage()
          Creates a new instance of LocalFileStorage
 
Method Summary
 void append(java.net.URI tailURI, java.net.URI headURI)
          Binary concatenate of the tail file to the head.
 void copy(java.net.URI sourceURI, java.net.URI targetURI, boolean overwriteOK)
          Copies the existing source to the target, overwriting the target if specified.
 java.net.URI createNewEntryURI(LogicalName logicalName, int version)
          This just creates the name, but does not validate it, beyond basic correctness, so whether this exists or not must be checked elsewhere.
 boolean delete(java.net.URI targetURI)
          Remove an entry from this store.
 boolean exists(java.net.URI targetURI)
          This returns a true if the specified target exists in this store.
 java.io.File getRepoRootDirectory()
           
 void initialize(java.util.Properties p, InitializationObjectInterface ioi)
           
 void isValidLogicalname(LogicalName logicalName)
          TODO This needs to have something more comprehensive in the way of checking.
 java.io.File logicalNameToFile(LogicalName ln, java.lang.String suffix)
          This will take a logical name and change it into either a path representation on the local file system or create a hash of it.
 long size(java.net.URI targetURI)
          The size of the entry in bytes.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

LOCAL_FILE_STORAGE_ROOT_KEY

public static java.lang.String LOCAL_FILE_STORAGE_ROOT_KEY
Constructor Detail

LocalFileStorage

public LocalFileStorage()
Creates a new instance of LocalFileStorage

Method Detail

copy

public void copy(java.net.URI sourceURI,
                 java.net.URI targetURI,
                 boolean overwriteOK)
          throws NFMSException
Description copied from interface: PermanentStorageInterface
Copies the existing source to the target, overwriting the target if specified. If the target exists and the overwriteOK flag is false then an exception is thrown. The append flag supercedes the overwrite flag.

Specified by:
copy in interface PermanentStorageInterface
Throws:
NFMSException

delete

public boolean delete(java.net.URI targetURI)
               throws NFMSException
Description copied from interface: PermanentStorageInterface
Remove an entry from this store. This is a true delete and the file is then completely removed.

Specified by:
delete in interface PermanentStorageInterface
Throws:
NFMSException

exists

public boolean exists(java.net.URI targetURI)
               throws NFMSException
Description copied from interface: PermanentStorageInterface
This returns a true if the specified target exists in this store.

Specified by:
exists in interface PermanentStorageInterface
Throws:
NFMSException

createNewEntryURI

public java.net.URI createNewEntryURI(LogicalName logicalName,
                                      int version)
                               throws NFMSException
This just creates the name, but does not validate it, beyond basic correctness, so whether this exists or not must be checked elsewhere.

Specified by:
createNewEntryURI in interface PermanentStorageInterface
Throws:
NFMSException

initialize

public void initialize(java.util.Properties p,
                       InitializationObjectInterface ioi)
                throws java.lang.Exception
Specified by:
initialize in interface InstantiationContractInterface
Throws:
java.lang.Exception

size

public long size(java.net.URI targetURI)
          throws NFMSException
Description copied from interface: PermanentStorageInterface
The size of the entry in bytes.

Specified by:
size in interface PermanentStorageInterface
Throws:
NFMSException

append

public void append(java.net.URI tailURI,
                   java.net.URI headURI)
            throws NFMSException
Description copied from interface: PermanentStorageInterface
Binary concatenate of the tail file to the head. Note that the target does not need to exist in which case this has the same functionality as the copy command.

Specified by:
append in interface PermanentStorageInterface
Throws:
NFMSException

getRepoRootDirectory

public java.io.File getRepoRootDirectory()
                                  throws NFMSException
Throws:
NFMSException

isValidLogicalname

public void isValidLogicalname(LogicalName logicalName)
                        throws NFMSIllegalLogicalNameException
TODO This needs to have something more comprehensive in the way of checking. Now it just checks that the path is valid on the system.

Specified by:
isValidLogicalname in interface PermanentStorageInterface
Throws:
NFMSIllegalLogicalNameException

logicalNameToFile

public java.io.File logicalNameToFile(LogicalName ln,
                                      java.lang.String suffix)
                               throws NFMSException
This will take a logical name and change it into either a path representation on the local file system or create a hash of it. If these two operations fail, then an exception is thrown. The failure modes are related to the underlying storage mechanism, specifically that most operating systems have a maximum length for the full path and it is possible to exceed this (hence the fallback position of making a hash). There could also be other failures beyond the control of the JVM (mounted drives vanishing and such). Suffice to say that every logical name can be munged into a platform neutral format, but there are still file system vagaries to contend with.

Throws:
NFMSException