fedora.server.storage
Class SimpleDOReader

java.lang.Object
  extended by fedora.server.storage.SimpleDOReader
All Implemented Interfaces:
DOReader
Direct Known Subclasses:
SimpleDOWriter, SimpleServiceAwareReader

public class SimpleDOReader
extends java.lang.Object
implements DOReader

A DOReader backed by a DigitalObject.

Version:
$Id: SimpleDOReader.java 6130 2007-09-18 19:15:50Z rwayland3 $
Author:
cwilper@cs.cornell.edu

Field Summary
protected  DigitalObject m_obj
           
 
Constructor Summary
SimpleDOReader(Context context, RepositoryReader repoReader, DOTranslator translator, java.lang.String exportFormat, java.lang.String encoding, DigitalObject obj)
          Alternate constructor for when a DigitalObject is already available for some reason.
SimpleDOReader(Context context, RepositoryReader repoReader, DOTranslator translator, java.lang.String exportFormat, java.lang.String storageFormat, java.lang.String encoding, java.io.InputStream serializedObject)
           
 
Method Summary
 java.io.InputStream ExportObject(java.lang.String format, java.lang.String exportContext)
          Return the object as an XML input stream in the specified XML format and in the specified export context.
 java.util.List getAuditRecords()
          Gets the entire list of audit records for the object.
 java.lang.String[] GetBehaviorDefs(java.util.Date versDateTime)
          Gets PIDs of Behavior Definitions to which object subscribes.
 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 particular Datastream in the digital object.
 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 datastreams as of a certain date and in a certain state.
 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)
          Same as getDatastream, but for disseminators.
 Disseminator[] GetDisseminators(java.util.Date versDateTime, java.lang.String state)
          Same as getDatastreams, but for disseminators.
 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 digital object.
 MethodParmDef[] getObjectMethodParms(java.lang.String bDefPID, java.lang.String methodName, java.util.Date versDateTime)
          Get the parameters for a given method.
 java.lang.String GetObjectPID()
          Gets the PID of the digital object.
 java.lang.String GetObjectState()
          Gets the state of the digital object.
 java.io.InputStream GetObjectXML()
          Return the object as an XML input stream in the internal serialization format.
 java.lang.String getOwnerId()
          Gets the userid of the user who owns the objects.
protected  java.lang.String getWhenString(java.util.Date versDateTime)
           
 java.lang.String[] ListDatastreamIDs(java.lang.String state)
          Gets a list of Datastream identifiers for all Datastreams in the digital object.
 java.lang.String[] ListDisseminatorIDs(java.lang.String state)
          Same as listDatastreamIds, but for disseminators.
 ObjectMethodsDef[] listMethods(java.util.Date versDateTime)
          Gets list of ALL method definitions that are available on a particular digital object.
 MethodDef[] listMethods(java.lang.String bDefPID, java.util.Date versDateTime)
          Gets list of method definitions that are available on a particular Disseminator.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

m_obj

protected DigitalObject m_obj
Constructor Detail

SimpleDOReader

public SimpleDOReader(Context context,
                      RepositoryReader repoReader,
                      DOTranslator translator,
                      java.lang.String exportFormat,
                      java.lang.String storageFormat,
                      java.lang.String encoding,
                      java.io.InputStream serializedObject)
               throws ObjectIntegrityException,
                      StreamIOException,
                      UnsupportedTranslationException,
                      ServerException
Throws:
ObjectIntegrityException
StreamIOException
UnsupportedTranslationException
ServerException

SimpleDOReader

public SimpleDOReader(Context context,
                      RepositoryReader repoReader,
                      DOTranslator translator,
                      java.lang.String exportFormat,
                      java.lang.String encoding,
                      DigitalObject obj)
Alternate constructor for when a DigitalObject is already available for some reason.

Method Detail

getFedoraObjectType

public java.lang.String getFedoraObjectType()
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.

getContentModelId

public java.lang.String getContentModelId()
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.

getCreateDate

public java.util.Date getCreateDate()
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.

getLastModDate

public java.util.Date getLastModDate()
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.

getOwnerId

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

Specified by:
getOwnerId in interface DOReader
Returns:
the userid

getAuditRecords

public java.util.List getAuditRecords()
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.

GetObjectXML

public java.io.InputStream GetObjectXML()
                                 throws ObjectIntegrityException,
                                        StreamIOException,
                                        UnsupportedTranslationException,
                                        ServerException
Return the object as an XML input stream in the internal serialization format.

Specified by:
GetObjectXML in interface DOReader
Returns:
the content of the entire digital object as XML.
Throws:
ServerException - If there object could not be found or there was was a failure in accessing the object for any reason.
ObjectIntegrityException
StreamIOException
UnsupportedTranslationException

ExportObject

public java.io.InputStream ExportObject(java.lang.String format,
                                        java.lang.String exportContext)
                                 throws ObjectIntegrityException,
                                        StreamIOException,
                                        UnsupportedTranslationException,
                                        ServerException
Return the object as an XML input stream in the specified XML format and in the specified export context. See DOTranslationUtility.class for description of export contexts (translation contexts).

Specified by:
ExportObject in interface DOReader
Parameters:
format - The format to export the object in. If null or "default", will use the repository's configured default export format.
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:
the content of the entire digital object as XML, with public URIs for managed content datastreams.
Throws:
ServerException - If there object could not be found or there was was a failure in accessing the object for any reason.
ObjectIntegrityException
StreamIOException
UnsupportedTranslationException

GetObjectPID

public java.lang.String GetObjectPID()
Description copied from interface: DOReader
Gets the PID of the digital object.

Specified by:
GetObjectPID in interface DOReader
Returns:
the PID of the digital object.

GetObjectLabel

public java.lang.String GetObjectLabel()
Description copied from interface: DOReader
Gets the label of the digital object.

Specified by:
GetObjectLabel in interface DOReader
Returns:
the label of the digital object.

GetObjectState

public java.lang.String GetObjectState()
Description copied from interface: DOReader
Gets the state of the digital object. The state indicates the status of the digital object at any point in time. Valid states are: A=Active, I=Inactive, D=Deleted

Specified by:
GetObjectState in interface DOReader
Returns:
the state of the digital object.

ListDatastreamIDs

public java.lang.String[] ListDatastreamIDs(java.lang.String state)
Description copied from interface: DOReader
Gets a list of Datastream identifiers for all Datastreams in the digital object. Will take a state parameter to specify that only Datastreams that are in a particular state should be listed (e.g., only active Datastreams with a state value of "A"). If state is given as null, all datastream ids will be returned, regardless of state.

Specified by:
ListDatastreamIDs in interface DOReader
Parameters:
state - The state of the Datastreams to be listed.
Returns:
a list of Datastream identifiers for all Datastreams in the digital object.

getDatastream

public Datastream getDatastream(java.lang.String dsID,
                                java.lang.String versionID)
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

GetDatastream

public Datastream GetDatastream(java.lang.String datastreamID,
                                java.util.Date versDateTime)
Description copied from interface: DOReader
Gets a particular Datastream in the digital object. If the date given is null, the most recent version of the datastream is given. If the date is non-null, the closest version of the Datastream to the specified date/time (without going over) is given. If no datastreams match the given criteria, null is returned.

Specified by:
GetDatastream in interface DOReader
Parameters:
datastreamID - The Datastream identifier
versDateTime - The date-time stamp to get appropriate Datastream version
Returns:
a particular Datastream in the digital object.

getDatastreamVersions

public java.util.Date[] getDatastreamVersions(java.lang.String datastreamID)
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.

getDisseminatorVersions

public java.util.Date[] getDisseminatorVersions(java.lang.String dissID)
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.

GetDatastreams

public Datastream[] GetDatastreams(java.util.Date versDateTime,
                                   java.lang.String state)
Description copied from interface: DOReader
Gets all datastreams as of a certain date and in a certain state. This iterates through all datastreams in the object and returns only those that existed at the given date/time, and currently have a certain state. If the date/time given is null, the most recent version of each datastream is obtained. If the state is null, all datastreams as of the given time will be returned, regardless of state.

Specified by:
GetDatastreams in interface DOReader
Parameters:
versDateTime - The date-time stamp to get appropriate Datastream versions
state - The state, null for any.
Returns:
all datastreams as of a certain date and in a certain state.

ListDisseminatorIDs

public java.lang.String[] ListDisseminatorIDs(java.lang.String state)
Description copied from interface: DOReader
Same as listDatastreamIds, but for disseminators.

Specified by:
ListDisseminatorIDs in interface DOReader
Parameters:
state - The state of the Disseminators to be listed.
Returns:
a list of Disseminator identifiers for all Disseminators in the digital object.

GetDisseminator

public Disseminator GetDisseminator(java.lang.String disseminatorID,
                                    java.util.Date versDateTime)
Description copied from interface: DOReader
Same as getDatastream, but for disseminators.

Specified by:
GetDisseminator in interface DOReader
Parameters:
disseminatorID - The Disseminator identifier
versDateTime - The date-time stamp to get appropriate Disseminator version
Returns:
a particular Disseminator in the digital object.

GetDisseminators

public Disseminator[] GetDisseminators(java.util.Date versDateTime,
                                       java.lang.String state)
Description copied from interface: DOReader
Same as getDatastreams, but for disseminators.

Specified by:
GetDisseminators in interface DOReader
Parameters:
versDateTime - The date-time stamp to get appropriate Disseminator version
state - The state of the disseminator.
Returns:
all Disseminators as of a certain date.

GetBehaviorDefs

public java.lang.String[] GetBehaviorDefs(java.util.Date versDateTime)
Description copied from interface: DOReader
Gets PIDs of Behavior Definitions to which object subscribes. This is done by looking at all the Disseminators for the object, and reflecting on what Behavior Definitions objects the Disseminators refer to. The given date is used to query for disseminators. The disseminators as they existed during the given date are used. If the date is given as null, the most recent version of each disseminator is used.

Specified by:
GetBehaviorDefs in interface DOReader
Parameters:
versDateTime - The date-time stamp to get appropriate version
Returns:
a list of PIDs of Behavior Definitions to which object subscribes.

getObjectHistory

public 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. 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.

listMethods

public MethodDef[] listMethods(java.lang.String bDefPID,
                               java.util.Date versDateTime)
                        throws MethodNotFoundException,
                               ServerException
Description copied from interface: DOReader
Gets list of method definitions that are available on a particular Disseminator. This is done by reflecting on the Disseminator that subscribes to the Behavior Definition that is specified in the method input parameter. Then, by reflecting on that Disseminator, the PID of the Behavior Mechanism object can be obtained. Finally, method implementation information can be found in the Behavior Mechanism object to which that Disseminator refers.

Specified by:
listMethods in interface DOReader
Parameters:
bDefPID - The PID of a Behavior Definition to which the object subscribes. If this is the special bootstrap bdef, this method returns null.
versDateTime - The date-time stamp to get appropriate version. If this is given as null, the most recent version is used.
Returns:
a list of method definitions that are available on a particular Disseminator.
Throws:
ServerException - If any type of error occurred fulfilling the request.
MethodNotFoundException

getObjectMethodParms

public MethodParmDef[] getObjectMethodParms(java.lang.String bDefPID,
                                            java.lang.String methodName,
                                            java.util.Date versDateTime)
                                     throws MethodNotFoundException,
                                            ServerException
Get the parameters for a given method. The parameters returned will be those that pertain to the abstract method definition, meaning they will only be user-supplied parms. Mechanism-specific parms (system default parms and datastream input parms) will be filtered out.

Specified by:
getObjectMethodParms in interface DOReader
Parameters:
bDefPID -
methodName -
versDateTime -
Returns:
an array of method parameter definitions
Throws:
DisseminatorNotFoundException
MethodNotFoundException
ServerException

getWhenString

protected java.lang.String getWhenString(java.util.Date versDateTime)

GetDSBindingMaps

public DSBindingMapAugmented[] GetDSBindingMaps(java.util.Date versDateTime)
                                         throws ObjectIntegrityException,
                                                ServerException
Description copied from interface: DOReader
Gets datastream binding map.

Specified by:
GetDSBindingMaps in interface DOReader
Parameters:
versDateTime - versioning datetime stamp
Returns:
DSBindingMapAugmented[] array of datastream binding maps
Throws:
ServerException - If anything went wrong
ObjectIntegrityException

getDisseminationBindingInfo

public DisseminationBindingInfo[] getDisseminationBindingInfo(java.lang.String bDefPID,
                                                              java.lang.String methodName,
                                                              java.util.Date versDateTime)
                                                       throws ServerException
Description copied from interface: DOReader
Gets the dissemination binding info necessary to perform a particular dissemination.

Specified by:
getDisseminationBindingInfo in interface DOReader
Parameters:
bDefPID - the behavior definition pid
methodName - the method name
versDateTime - versioning datetime stamp
Returns:
the dissemination binding info necessary to perform a particular dissemination.
Throws:
ServerException - If anything went wrong

listMethods

public ObjectMethodsDef[] listMethods(java.util.Date versDateTime)
                               throws ServerException
Description copied from interface: DOReader
Gets list of ALL method definitions that are available on a particular digital object. This is done by reflecting on EACH Disseminator and getting the PID of the behavior mechanism object for that disseminator. The methods are reflected via the behavior mechanism object, which is implementing the methods defined in a particular by a behavior definition.

Specified by:
listMethods in interface DOReader
Parameters:
versDateTime - The date-time stamp to get appropriate version. If this is given as null, the most recent version is used.
Returns:
a list of ALL method definitions that are available on a particular digital object.
Throws:
ServerException - If any type of error occurred fulfilling the request.