org.fcrepo.server.storage.lowlevel
Class DefaultLowlevelStorage

java.lang.Object
  extended by org.fcrepo.server.storage.lowlevel.DefaultLowlevelStorage
All Implemented Interfaces:
IListable, ILowlevelStorage, ISizable

public class DefaultLowlevelStorage
extends Object
implements ILowlevelStorage, IListable, ISizable

Author:
Bill Niebel

Field Summary
static String DATASTREAM_REGISTRY_TABLE
           
static String DATASTREAM_STORE_BASE
           
static String FILESYSTEM
           
static String OBJECT_REGISTRY_TABLE
           
static String OBJECT_STORE_BASE
           
static String PATH_ALGORITHM
           
static String PATH_REGISTRY
           
static String REGISTRY_NAME
           
 
Constructor Summary
DefaultLowlevelStorage(Map<String,Object> configuration)
           
 
Method Summary
 long addDatastream(String pid, InputStream content, Map<String,String> hints)
          Sets the content of a new datastream version.
 void addObject(String pid, InputStream content, Map<String,String> hints)
          Adds a new object.
 void auditDatastream()
          Performs a consistency check against the datastream index if such an index exists.
 void auditObject()
          Performs a consistency check against the object index if such an index exists.
 long getDatastreamSize(String dsKey)
          Return the size of a datastream in bytes
 Iterator<String> listDatastreams()
          Lists all stored datastreams in no particular order.
 Iterator<String> listObjects()
          Lists all stored objects in no particular order.
 void rebuildDatastream()
          Reconstructs the datastream index if such an index exists.
 void rebuildObject()
          Reconstructs the object index if such an index exists.
 void removeDatastream(String pid)
          Removes the content of an existing datastream version.
 void removeObject(String pid)
          Removes an object.
 long replaceDatastream(String pid, InputStream content, Map<String,String> hints)
          Sets the content of an existing datastream version.
 void replaceObject(String pid, InputStream content, Map<String,String> hints)
          Replaces an existing object.
 InputStream retrieveDatastream(String pid)
          Gets the content of an existing datastream version.
 InputStream retrieveObject(String pid)
          Gets an existing object.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

REGISTRY_NAME

public static final String REGISTRY_NAME
See Also:
Constant Field Values

OBJECT_REGISTRY_TABLE

public static final String OBJECT_REGISTRY_TABLE
See Also:
Constant Field Values

DATASTREAM_REGISTRY_TABLE

public static final String DATASTREAM_REGISTRY_TABLE
See Also:
Constant Field Values

OBJECT_STORE_BASE

public static final String OBJECT_STORE_BASE
See Also:
Constant Field Values

DATASTREAM_STORE_BASE

public static final String DATASTREAM_STORE_BASE
See Also:
Constant Field Values

FILESYSTEM

public static final String FILESYSTEM
See Also:
Constant Field Values

PATH_ALGORITHM

public static final String PATH_ALGORITHM
See Also:
Constant Field Values

PATH_REGISTRY

public static final String PATH_REGISTRY
See Also:
Constant Field Values
Constructor Detail

DefaultLowlevelStorage

public DefaultLowlevelStorage(Map<String,Object> configuration)
                       throws LowlevelStorageException
Throws:
LowlevelStorageException
Method Detail

addObject

public void addObject(String pid,
                      InputStream content,
                      Map<String,String> hints)
               throws LowlevelStorageException
Description copied from interface: ILowlevelStorage
Adds a new object.

Specified by:
addObject in interface ILowlevelStorage
Parameters:
pid - the pid of the object.
content - the serialized object.
hints - a map of hints for object storage
Throws:
LowlevelStorageException - if the object already exists or cannot be added for any other reason.

replaceObject

public void replaceObject(String pid,
                          InputStream content,
                          Map<String,String> hints)
                   throws LowlevelStorageException
Description copied from interface: ILowlevelStorage
Replaces an existing object.

Specified by:
replaceObject in interface ILowlevelStorage
Parameters:
pid - the pid of the object.
content - the serialized object.
Throws:
LowlevelStorageException - if the object does not already exist or cannot be replaced for any other reason.

retrieveObject

public InputStream retrieveObject(String pid)
                           throws LowlevelStorageException
Description copied from interface: ILowlevelStorage
Gets an existing object.

Specified by:
retrieveObject in interface ILowlevelStorage
Parameters:
pid - the pid of the object.
Returns:
the serialized form of the object, as stored.
Throws:
LowlevelStorageException - if the object does not exist or cannot be read for any other reason.

removeObject

public void removeObject(String pid)
                  throws LowlevelStorageException
Description copied from interface: ILowlevelStorage
Removes an object.

Specified by:
removeObject in interface ILowlevelStorage
Parameters:
pid - the pid of the object.
Throws:
LowlevelStorageException - if the object does not exist or cannot be removed for any other reason.

rebuildObject

public void rebuildObject()
                   throws LowlevelStorageException
Description copied from interface: ILowlevelStorage
Reconstructs the object index if such an index exists. The object index associates an object with a stored location. If the implementation does not use an index, this is a no-op.

Warning

Rebuilding the object index is not expected to be an atomic operation and should only be run while the system is offline or reads and writes are otherwise prevented.

Specified by:
rebuildObject in interface ILowlevelStorage
Throws:
LowlevelStorageException - if an error occurs that prevents the index from being rebuilt.

auditObject

public void auditObject()
                 throws LowlevelStorageException
Description copied from interface: ILowlevelStorage
Performs a consistency check against the object index if such an index exists. The object index associates an object with a stored location. If the implementation does not use an index, this is a no-op. If any inconsistencies are found, they will be reported to the system logger.

Specified by:
auditObject in interface ILowlevelStorage
Throws:
LowlevelStorageException - if an error occurs that prevents the consistency check from taking place.

addDatastream

public long addDatastream(String pid,
                          InputStream content,
                          Map<String,String> hints)
                   throws LowlevelStorageException
Description copied from interface: ILowlevelStorage
Sets the content of a new datastream version.

Specified by:
addDatastream in interface ILowlevelStorage
Parameters:
pid - the $pid "+" $dsId "+" $dsVersionId string that uniquely identifies the datastream version.
content - the content.
Throws:
LowlevelStorageException - if the datastream version already exists or cannot be added for any other reason.

replaceDatastream

public long replaceDatastream(String pid,
                              InputStream content,
                              Map<String,String> hints)
                       throws LowlevelStorageException
Description copied from interface: ILowlevelStorage
Sets the content of an existing datastream version.

Specified by:
replaceDatastream in interface ILowlevelStorage
Parameters:
pid - the $pid "+" $dsId "+" $dsVersionId string that uniquely identifies the datastream version.
content - the content.
Throws:
LowlevelStorageException - if the datastream version does not already exist or cannot be replaced for any other reason.

retrieveDatastream

public InputStream retrieveDatastream(String pid)
                               throws LowlevelStorageException
Description copied from interface: ILowlevelStorage
Gets the content of an existing datastream version.

Specified by:
retrieveDatastream in interface ILowlevelStorage
Parameters:
pid - the $pid "+" $dsId "+" $dsVersionId string that uniquely identifies the datastream version.
Returns:
the content.
Throws:
LowlevelStorageException - if the datastream version does not exist or cannot be read for any other reason.

removeDatastream

public void removeDatastream(String pid)
                      throws LowlevelStorageException
Description copied from interface: ILowlevelStorage
Removes the content of an existing datastream version.

Specified by:
removeDatastream in interface ILowlevelStorage
Parameters:
pid - the $pid "+" $dsId "+" $dsVersionId string that uniquely identifies the datastream version.
Throws:
LowlevelStorageException - if the datastream version does not exist or cannot be removed for any other reason.

rebuildDatastream

public void rebuildDatastream()
                       throws LowlevelStorageException
Description copied from interface: ILowlevelStorage
Reconstructs the datastream index if such an index exists. The datastream index associates a datastream version with a stored location. If the implementation does not use an index, this is a no-op.

Warning

Rebuilding the datastream index is not expected to be an atomic operation and should only be run while the system is offline or reads and writes are otherwise prevented.

Specified by:
rebuildDatastream in interface ILowlevelStorage
Throws:
LowlevelStorageException - if an error occurs that prevents the

auditDatastream

public void auditDatastream()
                     throws LowlevelStorageException
Description copied from interface: ILowlevelStorage
Performs a consistency check against the datastream index if such an index exists. The datastream index associates a datastream version with a stored location. If the implementation does not use an index, this is a no-op. If any inconsistencies are found, they will be reported to the system logger.

Specified by:
auditDatastream in interface ILowlevelStorage
Throws:
LowlevelStorageException - if an error occurs that prevents the consistency check from taking place.

listObjects

public Iterator<String> listObjects()
Description copied from interface: IListable
Lists all stored objects in no particular order.

Specified by:
listObjects in interface IListable
Returns:
an iterator of all stored object pids.

listDatastreams

public Iterator<String> listDatastreams()
Description copied from interface: IListable
Lists all stored datastreams in no particular order.

Specified by:
listDatastreams in interface IListable
Returns:
an iterator of all stored datastream keys, each in the following format: $pid "+" $dsId "+" $dsVersionId

getDatastreamSize

public long getDatastreamSize(String dsKey)
                       throws LowlevelStorageException
Description copied from interface: ISizable
Return the size of a datastream in bytes

Specified by:
getDatastreamSize in interface ISizable
Returns:
Throws:
LowlevelStorageException


Copyright © 2012 DuraSpace. All Rights Reserved.