fedora.server.storage
Class FastDOReader

java.lang.Object
  extended by fedora.server.storage.FastDOReader
All Implemented Interfaces:
DOReader
Direct Known Subclasses:
FastBdefReader, FastBmechReader

public class FastDOReader
extends java.lang.Object
implements DOReader

Title: FastDOReader.java

Description: Digital Object Reader that accesses objects located in the "Fast" storage area. To enhance performance of disseminations, there are two distinct storage areas for digital objects:

  1. "Fast" storage area - The storage area containing a subset of digital objects that is optimized for performance. Both the composition of the subset of objects and storage area are implementation specific. For Phase 1, this object subset consists of a partial replication of the most current version of each object and is used as the primary source for resolving dissemination requests. The replication is partial since only information required to disseminate the object is replicated in the Fast storage area. For Phase 1, the Fast storage area is implemented as a relational database that is accessed via JDBC. Note that an appropriate definitve reader should always be used to obtain the most complete information about a specific object. A fast reader is used primarily for dissemination requests..
  2. Definitive storage area - The storage area containing complete information on all digital objects in the repository. This storage area is used as the authoritative source for reading complete information about a digital object. This storage area is used as a secondary source for resolving dissemination requests when the specified object does not exist in the Fast storage area.

This reader is designed to read objects from the "Fast" storage area that is implemented as a relational database. If the object cannot be found in the relational database, this reader will attempt to read the object from the Definitive storage area using the appropriate definitive reader. When the object exists in both storage areas, preference is given to the Fast storage area since this reader is designed to read primarily from the Fast Storage area. SimpleDODOReader should always be used to read the authoritative version of an object.

Note that versioning is not implemented in Phase 1. Methods in FastDOReader that contain arguments related to versioning date such as versDateTime or asOfDate will be ignored in Phase 1.

Version:
$Id: FastDOReader.java 5313 2006-12-06 12:14:27Z cwilper $
Author:
rlw@virginia.edu

Field Summary
protected static ConnectionPool connectionPool
          Database ConnectionPool instance
protected  DOReader definitiveDOReader
          Instance of DOReader...
protected  java.lang.String doLabel
          Label of the digital object.
protected static java.lang.String fedoraServerHost
          Host name of the Fedora server
protected static java.lang.String fedoraServerPort
          Port number on which the Fedora server is running.
protected  boolean isFoundInDefinitiveStore
          signals object found in definitive storage area
protected  boolean isFoundInFastStore
          Signals object found in fast storage area
protected  Context m_context
           
protected static DOManager m_manager
          Current Fedora server DOManager instance
protected  java.lang.String PID
          Persistent identifier of the digital object.
protected static Server s_server
          Fedora server instance
 
Constructor Summary
FastDOReader(Context context, java.lang.String objectPID)
          Constructs a new FastDOReader for the specified digital object.
 
Method Summary
 java.io.InputStream ExportObject(java.lang.String format, java.lang.String exportContext)
          Exports the object.
 java.util.List<AuditRecord> getAuditRecords()
          Gets the entire list of audit records for the object.
 java.lang.String[] GetBehaviorDefs(java.util.Date versDateTime)
          Gets a list of Behavior Definition object PIDs associated with the specified digital object.
 java.lang.String getContentModelId()
          Gets the content model of the object.
 java.util.Date getCreateDate()
          Gets the date of creation of this object.
 Datastream GetDatastream(java.lang.String datastreamID, java.util.Date versDateTime)
          Gets a datastream specified by the datastream ID.
 Datastream getDatastream(java.lang.String dsID, java.lang.String versionID)
          Gets a particular datastream in the digital object.
 Datastream[] GetDatastreams(java.util.Date versDateTime, java.lang.String state)
          Gets all the datastreams of a digital object.
 java.util.Date[] getDatastreamVersions(java.lang.String datastreamID)
          Gets the creation dates of all versions of a particular datastream, in no particular order.
 DisseminationBindingInfo[] getDisseminationBindingInfo(java.lang.String bDefPID, java.lang.String methodName, java.util.Date versDateTime)
          Gets the dissemination binding info necessary to perform a particular dissemination.
 Disseminator GetDisseminator(java.lang.String disseminatorID, java.util.Date versDateTime)
          Gets a disseminator with the specified ID.
 Disseminator[] GetDisseminators(java.util.Date versDateTime, java.lang.String state)
          Gets all disseminators of the specified object.
 java.util.Date[] getDisseminatorVersions(java.lang.String dissID)
          Gets the creation dates of all versions of a particular disseminator, in no particular order.
 DSBindingMapAugmented[] GetDSBindingMaps(java.util.Date versDateTime)
          Gets datastream binding map.
 java.lang.String getFedoraObjectType()
          Gets the type of fedora object (O=FEDORA_OBJECT, D=FEDORA_BDEF_OBJECT, M=FEDORA_BMECH_OBJECT) this is a handle on.
 java.util.Date getLastModDate()
          Gets the date of the last modification of this object.
 java.lang.String[] getObjectHistory(java.lang.String PID)
          Gets the change history of an object by returning a list of timestamps that correspond to modification dates of components.
 java.lang.String GetObjectLabel()
          Gets the label of the requested object.
 MethodParmDef[] getObjectMethodParms(java.lang.String bDefPID, java.lang.String methodName, java.util.Date versDateTime)
          Gets method parameters associated with the specified method name.
 java.lang.String GetObjectPID()
          Gets the persistent identifier or PID of the digital object.
 java.lang.String GetObjectState()
          Gets the state on a digital object
 java.io.InputStream GetObjectXML()
          Gets the XML representation of the object.
 java.lang.String getOwnerId()
          Gets the userid of the user who owns the objects.
 java.lang.String[] ListDatastreamIDs(java.lang.String state)
          Lists the datastream IDs of the requested object having the specified state.
 java.lang.String[] ListDisseminatorIDs(java.lang.String state)
          Gets a list of disseminator IDs.
 ObjectMethodsDef[] listMethods(java.util.Date versDateTime)
          Gets all methods associated with the specified digital object.
 MethodDef[] listMethods(java.lang.String bDefPID, java.util.Date versDateTime)
          Gets all method defintiions associated with the specified Behavior Mechanism.
 java.lang.String locatePID(java.lang.String PID)
          Locates the specified digital object using its persitent identifier.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

connectionPool

protected static ConnectionPool connectionPool
Database ConnectionPool instance


s_server

protected static Server s_server
Fedora server instance


m_manager

protected static DOManager m_manager
Current Fedora server DOManager instance


isFoundInFastStore

protected boolean isFoundInFastStore
Signals object found in fast storage area


isFoundInDefinitiveStore

protected boolean isFoundInDefinitiveStore
signals object found in definitive storage area


doLabel

protected java.lang.String doLabel
Label of the digital object.


PID

protected java.lang.String PID
Persistent identifier of the digital object.


definitiveDOReader

protected DOReader definitiveDOReader
Instance of DOReader... used to get definitive readers.


fedoraServerHost

protected static java.lang.String fedoraServerHost
Host name of the Fedora server


fedoraServerPort

protected static java.lang.String fedoraServerPort
Port number on which the Fedora server is running.


m_context

protected Context m_context
Constructor Detail

FastDOReader

public FastDOReader(Context context,
                    java.lang.String objectPID)
             throws ServerException

Constructs a new FastDOReader for the specified digital object. It initializes the database connection for JDBC access to the relational database and verifies existence of the specified object. If the object is found, this constructor initializes the class variables for PID and doLabel.

Parameters:
context - The context of this request.
objectPID - The persistent identifier of the digital object.
Throws:
ServerException - If any type of error occurred fulfilling the request.
Method Detail

ExportObject

public java.io.InputStream ExportObject(java.lang.String format,
                                        java.lang.String exportContext)
                                 throws StreamIOException,
                                        GeneralException

Exports the object. Since the XML representation of an object is not stored in the Fast storage area, this method always queries the Definitive storage area using SimpleDOReader.

Specified by:
ExportObject in interface DOReader
Parameters:
format - The XML format to export (e.g., foxml1.0, metslikefedora1)
exportContext - The use case for export (public, migrate, archive) which results in different ways of representing datastream URLs or datastream content in the output.
Returns:
A stream of bytes consisting of the XML-encoded representation of the digital object.
Throws:
StreamIOException - If there is a problem in getting the XML input stream.
GeneralException - If there was any misc exception that we want to catch and re-throw as a Fedora exception. Extends ServerException.

getContentModelId

public java.lang.String getContentModelId()
                                   throws ServerException
Description copied from interface: DOReader
Gets the content model of the object.

Specified by:
getContentModelId in interface DOReader
Returns:
the content model of the object.
Throws:
ServerException - If any type of error occurred fulfilling the request.

getFedoraObjectType

public java.lang.String getFedoraObjectType()
                                     throws ServerException
Description copied from interface: DOReader
Gets the type of fedora object (O=FEDORA_OBJECT, D=FEDORA_BDEF_OBJECT, M=FEDORA_BMECH_OBJECT) this is a handle on.

Specified by:
getFedoraObjectType in interface DOReader
Returns:
the type of Fedora object.
Throws:
ServerException - If any type of error occurred fulfilling the request.

getCreateDate

public java.util.Date getCreateDate()
                             throws ServerException
Description copied from interface: DOReader
Gets the date of creation of this object.

Specified by:
getCreateDate in interface DOReader
Returns:
the date of creation of this object.
Throws:
ServerException - If any type of error occurred fulfilling the request.

getLastModDate

public java.util.Date getLastModDate()
                              throws ServerException
Description copied from interface: DOReader
Gets the date of the last modification of this object.

Specified by:
getLastModDate in interface DOReader
Returns:
the date of the last modification of this object.
Throws:
ServerException - If any type of error occurred fulfilling the request.

GetBehaviorDefs

public java.lang.String[] GetBehaviorDefs(java.util.Date versDateTime)
                                   throws GeneralException

Gets a list of Behavior Definition object PIDs associated with the specified digital object.

Specified by:
GetBehaviorDefs in interface DOReader
Parameters:
versDateTime - The versioning datetime stamp.
Returns:
An array containing a list of Behavior Definition object PIDs.
Throws:
GeneralException - If there was any misc exception that we want to catch and re-throw as a Fedora exception. Extends ServerException.

getObjectMethodParms

public MethodParmDef[] getObjectMethodParms(java.lang.String bDefPID,
                                            java.lang.String methodName,
                                            java.util.Date versDateTime)
                                     throws GeneralException

Gets method parameters associated with the specified method name.

Specified by:
getObjectMethodParms in interface DOReader
Parameters:
bDefPID - The persistent identifer of Behavior Definition object.
methodName - The name of the method.
versDateTime - The versioning datetime stamp.
Returns:
An array of method parameter definitions.
Throws:
GeneralException - If there was any misc exception that we want to catch and re-throw as a Fedora exception. Extends ServerException.

listMethods

public MethodDef[] listMethods(java.lang.String bDefPID,
                               java.util.Date versDateTime)
                        throws GeneralException

Gets all method defintiions associated with the specified Behavior Mechanism. Note the PID of the associated Behavior Mechanism object is determined via reflection based on the specified PID of the digital object and the PID of its Behavior Definition object. This method retrieves the list of available methods based on the assocaited Behavior Mechanism object and NOT the Behavior Definition object. This is done to insure that only methods that have been implemented in the mechanism are returned. This distinction is only important when versioning is enabled in a later release. When versioning is enabled, it is possible that a versioned Behavior Definition may have methods that have not yet been implemented by all of its associated Behavior Mechanisms. In such a case, only those methods implemented in the mechanism will be returned.

Specified by:
listMethods in interface DOReader
Parameters:
bDefPID - The persistent identifier of Behavior Definition object.
versDateTime - The versioning datetime stamp.
Returns:
An array of method definitions.
Throws:
GeneralException - If there was any misc exception that we want to catch and re-throw as a Fedora exception. Extends ServerException.

GetDatastream

public Datastream GetDatastream(java.lang.String datastreamID,
                                java.util.Date versDateTime)
                         throws GeneralException

Gets a datastream specified by the datastream ID.

Specified by:
GetDatastream in interface DOReader
Parameters:
datastreamID - The identifier of the requested datastream.
versDateTime - The versioning datetime stamp.
Returns:
The specified datastream.
Throws:
GeneralException - If there was any misc exception that we want to catch and re-throw as a Fedora exception. Extends ServerException.

GetDatastreams

public Datastream[] GetDatastreams(java.util.Date versDateTime,
                                   java.lang.String state)
                            throws GeneralException

Gets all the datastreams of a digital object.

Specified by:
GetDatastreams in interface DOReader
Parameters:
versDateTime - The versioning datetime stamp.
state - The state of the datastreams to get, null if any.
Returns:
An array of datastreams.
Throws:
GeneralException - If there was any misc exception that we want to catch and re-throw as a Fedora exception. Extends ServerException.

getDatastream

public Datastream getDatastream(java.lang.String dsID,
                                java.lang.String versionID)
                         throws GeneralException
Description copied from interface: DOReader
Gets a particular datastream in the digital object. This is an alternative to retrieving a datastream if all that is known is the version id (and not the date). The datastream id and version id must match actual ids of an existing datastream in the object. Otherwise, null will be returned.

Specified by:
getDatastream in interface DOReader
Parameters:
dsID - The datastream identifier
versionID - The identifier of the particular version
Returns:
a particular Datastream in the digital object
Throws:
GeneralException

getDatastreamVersions

public java.util.Date[] getDatastreamVersions(java.lang.String datastreamID)
                                       throws ServerException
Description copied from interface: DOReader
Gets the creation dates of all versions of a particular datastream, in no particular order.

Specified by:
getDatastreamVersions in interface DOReader
Parameters:
datastreamID - The datastream identifier
Returns:
the creation dates.
Throws:
ServerException - If any type of error occurred fulfilling the request.

getDisseminatorVersions

public java.util.Date[] getDisseminatorVersions(java.lang.String dissID)
                                         throws ServerException
Description copied from interface: DOReader
Gets the creation dates of all versions of a particular disseminator, in no particular order.

Specified by:
getDisseminatorVersions in interface DOReader
Parameters:
dissID - The disseminator identifier
Returns:
the creation dates.
Throws:
ServerException - If any type of error occurred fulfilling the request.

getDisseminationBindingInfo

public DisseminationBindingInfo[] getDisseminationBindingInfo(java.lang.String bDefPID,
                                                              java.lang.String methodName,
                                                              java.util.Date versDateTime)
                                                       throws GeneralException
Gets the dissemination binding info necessary to perform a particular dissemination.

Specified by:
getDisseminationBindingInfo in interface DOReader
Parameters:
bDefPID - The identifier for behavior definition object.
methodName - The name of the method.
versDateTime - The versioning DateTime stamp.
Returns:
the dissemination binding info necessary to perform a particular dissemination.
Throws:
GeneralException - If there was any misc exception that we want to catch and re-throw as a Fedora exception. Extends ServerException.

GetDisseminator

public Disseminator GetDisseminator(java.lang.String disseminatorID,
                                    java.util.Date versDateTime)
                             throws GeneralException

Gets a disseminator with the specified ID.

Specified by:
GetDisseminator in interface DOReader
Parameters:
disseminatorID - the identifier of the requested disseminator
versDateTime - versioning datetime stamp
Returns:
Disseminator
Throws:
GeneralException - If there was any misc exception that we want to catch and re-throw as a Fedora exception. Extends ServerException.

GetDisseminators

public Disseminator[] GetDisseminators(java.util.Date versDateTime,
                                       java.lang.String state)
                                throws GeneralException

Gets all disseminators of the specified object.

Specified by:
GetDisseminators in interface DOReader
Parameters:
versDateTime - versioning datetime stamp
state - The state of disseminators to be retrieved.
Returns:
Disseminator[] array of disseminators
Throws:
GeneralException - If there was any misc exception that we want to catch and re-throw as a Fedora exception. Extends ServerException.

GetDSBindingMaps

public DSBindingMapAugmented[] GetDSBindingMaps(java.util.Date versDateTime)
                                         throws GeneralException

Gets datastream binding map.

Specified by:
GetDSBindingMaps in interface DOReader
Parameters:
versDateTime - versioning datetime stamp
Returns:
DSBindingMapAugmented[] array of datastream binding maps
Throws:
GeneralException - If there was any misc exception that we want to catch and re-throw as a Fedora exception. Extends ServerException.

GetObjectLabel

public java.lang.String GetObjectLabel()
                                throws GeneralException

Gets the label of the requested object.

Specified by:
GetObjectLabel in interface DOReader
Returns:
String contining the object label
Throws:
GeneralException - If there was any misc exception that we want to catch and re-throw as a Fedora exception. Extends ServerException.

listMethods

public ObjectMethodsDef[] listMethods(java.util.Date versDateTime)
                               throws GeneralException

Gets all methods associated with the specified digital object. If the object is found, an array of ObjectMethodsDef is returned. If the object cannot be found in the relational database, the method attempts to find the object in the Definitive storage area. If the object cannot be found, ObjectNotFoundException is thrown.

Specified by:
listMethods in interface DOReader
Parameters:
versDateTime - The versioning datetime stamp.
Returns:
ObjectMethodsDef containing all object methods
Throws:
GeneralException - If there was any misc exception that we want to catch and re-throw as a Fedora exception. Extends ServerException.

GetObjectPID

public java.lang.String GetObjectPID()
                              throws GeneralException

Gets the persistent identifier or PID of the digital object.

Specified by:
GetObjectPID in interface DOReader
Returns:
String containing the persistent identifier
Throws:
GeneralException - If there was any misc exception that we want to catch and re-throw as a Fedora exception. Extends ServerException.

GetObjectState

public java.lang.String GetObjectState()
                                throws GeneralException

Gets the state on a digital object

Specified by:
GetObjectState in interface DOReader
Returns:
String state of the object
Throws:
GeneralException - If there was any misc exception that we want to catch and re-throw as a Fedora exception. Extends ServerException.

getObjectHistory

public java.lang.String[] getObjectHistory(java.lang.String PID)
                                    throws GeneralException

Gets the change history of an object by returning a list of timestamps that correspond to modification dates of components. This currently includes changes to datastreams and disseminators.

Specified by:
getObjectHistory in interface DOReader
Parameters:
PID - The persistent identifier of the digitla object.
Returns:
An Array containing the list of timestamps indicating when changes were made to the object.
Throws:
GeneralException - If any type of error occurred fulfilling the request.

getOwnerId

public java.lang.String getOwnerId()
                            throws ServerException,
                                   StorageDeviceException,
                                   ObjectNotFoundException
Description copied from interface: DOReader
Gets the userid of the user who owns the objects.

Specified by:
getOwnerId in interface DOReader
Returns:
the userid
Throws:
ServerException - If any type of error occurred fulfilling the request.
StorageDeviceException
ObjectNotFoundException

getAuditRecords

public java.util.List<AuditRecord> getAuditRecords()
                                            throws ServerException,
                                                   StorageDeviceException,
                                                   ObjectNotFoundException
Description copied from interface: DOReader
Gets the entire list of audit records for the object. Changes to the list affect the underlying object if this is DOWriter.

Specified by:
getAuditRecords in interface DOReader
Returns:
the entire list of audit records for the object.
Throws:
ServerException - If any type of error occurred fulfilling the request.
StorageDeviceException
ObjectNotFoundException

GetObjectXML

public java.io.InputStream GetObjectXML()
                                 throws StreamIOException,
                                        GeneralException

Gets the XML representation of the object. Since the XML representation of an object is not stored in the Fast storage area, this method always queries the Definitive storage area using DefinitveDOReader.

Specified by:
GetObjectXML in interface DOReader
Returns:
String containing the XML representation of the object.
Throws:
GeneralException - If there was any misc exception that we want to catch and re-throw as a Fedora exception. Extends ServerException.
StreamIOException - If there was a failure in accessing the object for any IO reason during retrieval of the object from low-level storage. Extends ServerException.

ListDatastreamIDs

public java.lang.String[] ListDatastreamIDs(java.lang.String state)
                                     throws GeneralException

Lists the datastream IDs of the requested object having the specified state. Note that the Fast storage area does NOT contain state information so state is ignored when querying the Fast storage area. DefinitiveDOReader should be used instead to list datastream IDs with a given state.

Specified by:
ListDatastreamIDs in interface DOReader
Parameters:
state - State of the datastreams.
Returns:
An array containing the datastream IDs.
Throws:
GeneralException - If there was any misc exception that we want to catch and re-throw as a Fedora exception. Extends ServerException.

ListDisseminatorIDs

public java.lang.String[] ListDisseminatorIDs(java.lang.String state)
                                       throws GeneralException
Gets a list of disseminator IDs. Note that the Fast storage area does not contain state information and state is ignored. DefinitiveDOReader should be used to list disseminator IDs when state is specified.

Specified by:
ListDisseminatorIDs in interface DOReader
Parameters:
state - State of the disseminators.
Returns:
An array listing disseminator IDs.
Throws:
GeneralException - If there was any misc exception that we want to catch and re-throw as a Fedora exception. Extends ServerException.

locatePID

public java.lang.String locatePID(java.lang.String PID)
                           throws GeneralException,
                                  ServerException

Locates the specified digital object using its persitent identifier. This method will first attempt to locate the object in the Fast storage area. If the the object cannot be located there, it will then try to find it in the Definitive strorage area. If the object is found, the object's label is returned. Otherwise, it throws ObjectNotFoundException.

Parameters:
PID - persistent identifier of the digital object.
Returns:
String containing label of the specified digital object.
Throws:
GeneralException - If there was any misc exception that we want to catch and re-throw as a Fedora exception. Extends ServerException.
ServerException - If any type of error occurred fulfilling the request.