org.fcrepo.server.storage
Class SimpleDOReader

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

public class SimpleDOReader
extends Object
implements DOReader

A DOReader backed by a DigitalObject.

Author:
Chris Wilper

Field Summary
protected  DigitalObject m_obj
           
 
Constructor Summary
SimpleDOReader(Context context, RepositoryReader repoReader, DOTranslator translator, String exportFormat, String encoding, DigitalObject obj)
          Alternate constructor for when a DigitalObject is already available for some reason.
SimpleDOReader(Context context, RepositoryReader repoReader, DOTranslator translator, String exportFormat, String storageFormat, String encoding, InputStream serializedObject)
           
 
Method Summary
 InputStream Export(String format, String exportContext)
          Gets the content of the entire digital object as XML, with public URIs as references to managed content datastreams under the custodianship of the repository.
 InputStream ExportObject(String format, String exportContext)
          Deprecated. in Fedora 3.0, use Export instead
 List<AuditRecord> getAuditRecords()
          Gets the entire list of audit records for the object.
 List<String> getContentModels()
          Gets a list of the content models of the object.
 Date getCreateDate()
          Gets the date of creation of this object.
 Datastream GetDatastream(String datastreamID, Date versDateTime)
          Gets a particular Datastream in the digital object.
 Datastream getDatastream(String dsID, String versionID)
          Gets a particular datastream in the digital object.
 Datastream[] GetDatastreams(Date versDateTime, String state)
          Gets all datastreams as of a certain date and in a certain state.
 Date[] getDatastreamVersions(String datastreamID)
          Gets the creation dates of all versions of a particular datastream, in no particular order.
 Date getLastModDate()
          Gets the date of the last modification of this object.
 DigitalObject getObject()
          Gets the underlying digital object this reader is working with.
 String[] getObjectHistory(String PID)
          Gets the change history of an object by returning a list of timestamps that correspond to modification dates of components.
 String GetObjectLabel()
          Gets the label of the digital object.
 String GetObjectPID()
          Gets the PID of the digital object.
 String GetObjectState()
          Gets the state of the digital object.
 InputStream GetObjectXML()
          Return the object as an XML input stream in the internal serialization format.
 String getOwnerId()
          Gets the userid of the user who owns the objects.
 Set<RelationshipTuple> getRelationships()
          Get all RELS-EXT and RELS-INT relationships in the object.
 Set<RelationshipTuple> getRelationships(org.jrdf.graph.PredicateNode predicate, org.jrdf.graph.ObjectNode object)
          Get all matching RELS-EXT relationships in the object, assumes pid is the subject
 Set<RelationshipTuple> getRelationships(org.jrdf.graph.SubjectNode subject, org.jrdf.graph.PredicateNode predicate, org.jrdf.graph.ObjectNode object)
          Get all matching RELS-EXT and RELS-INT relationships in the object.
protected  String getWhenString(Date versDateTime)
           
 boolean hasContentModel(org.jrdf.graph.ObjectNode contentModel)
          Determins whether or not the object have the given uri as a content model.
 boolean hasRelationship(org.jrdf.graph.PredicateNode predicate, org.jrdf.graph.ObjectNode object)
          Determine if the object contains the given relationship, assumes pid as the subject.
 boolean hasRelationship(org.jrdf.graph.SubjectNode subject, org.jrdf.graph.PredicateNode predicate, org.jrdf.graph.ObjectNode object)
          Determine if the object contains the given relationship.
 String[] ListDatastreamIDs(String state)
          Gets a list of Datastream identifiers for all Datastreams in the digital object.
 ObjectMethodsDef[] listMethods(Date versDateTime)
          Gets list of ALL method definitions that are available on a particular digital object.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

m_obj

protected final DigitalObject m_obj
Constructor Detail

SimpleDOReader

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

SimpleDOReader

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

Method Detail

getObject

public DigitalObject getObject()
Gets the underlying digital object this reader is working with.

Specified by:
getObject in interface DOReader

getCreateDate

public Date getCreateDate()
Gets the date of creation of this object.

Specified by:
getCreateDate in interface DOReader
Returns:
the date of creation of this object.

getLastModDate

public Date getLastModDate()
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 String getOwnerId()
Gets the userid of the user who owns the objects.

Specified by:
getOwnerId in interface DOReader
Returns:
the userid

getAuditRecords

public List<AuditRecord> getAuditRecords()
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 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

Export

public InputStream Export(String format,
                          String exportContext)
                   throws ObjectIntegrityException,
                          StreamIOException,
                          UnsupportedTranslationException,
                          ServerException
Gets the content of the entire digital object as XML, with public URIs as references to managed content datastreams under the custodianship of the repository.

The intent of this method is to return the digital object along with valid URI pointers for ALL its datastreams.

Specified by:
Export 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
See Also:
DOTranslationUtility.SERIALIZE_EXPORT_PUBLIC, DOTranslationUtility.SERIALIZE_EXPORT_MIGRATE, DOTranslationUtility.SERIALIZE_EXPORT_ARCHIVE

ExportObject

@Deprecated
public InputStream ExportObject(String format,
                                           String exportContext)
                         throws ObjectIntegrityException,
                                StreamIOException,
                                UnsupportedTranslationException,
                                ServerException
Deprecated. in Fedora 3.0, use Export instead

Specified by:
ExportObject in interface DOReader
Throws:
ObjectIntegrityException
StreamIOException
UnsupportedTranslationException
ServerException

GetObjectPID

public String GetObjectPID()
Gets the PID of the digital object.

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

GetObjectLabel

public String GetObjectLabel()
Gets the label of the digital object.

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

GetObjectState

public String GetObjectState()
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.

getContentModels

public List<String> getContentModels()
                              throws ServerException
Description copied from interface: DOReader
Gets a list of the content models of the object. The strings will be of the format "info:fedora/PID"

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

hasContentModel

public boolean hasContentModel(org.jrdf.graph.ObjectNode contentModel)
                        throws ServerException
Description copied from interface: DOReader
Determins whether or not the object have the given uri as a content model.

Specified by:
hasContentModel in interface DOReader
Parameters:
contentModel - The object node of the content model
Returns:
true if the object have the content model.
Throws:
ServerException

ListDatastreamIDs

public String[] ListDatastreamIDs(String state)
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(String dsID,
                                String versionID)
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(String datastreamID,
                                Date versDateTime)
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 Date[] getDatastreamVersions(String datastreamID)
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.

GetDatastreams

public Datastream[] GetDatastreams(Date versDateTime,
                                   String state)
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.

getObjectHistory

public String[] getObjectHistory(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.

getWhenString

protected String getWhenString(Date versDateTime)

listMethods

public ObjectMethodsDef[] listMethods(Date versDateTime)
                               throws ServerException
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 service deployment object for that disseminator. The methods are reflected via the service deployment 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.

hasRelationship

public boolean hasRelationship(org.jrdf.graph.SubjectNode subject,
                               org.jrdf.graph.PredicateNode predicate,
                               org.jrdf.graph.ObjectNode object)
Determine if the object contains the given relationship.

Specified by:
hasRelationship in interface DOReader
Parameters:
subject - Subject of the relationship, or null if unspecified (will match any).
predicate - Predicate of the relationship, or null if unspecified (will match any).
object - Object (target) of the relationship, or null if unspecified (will match any).
Returns:
true if the object

hasRelationship

public boolean hasRelationship(org.jrdf.graph.PredicateNode predicate,
                               org.jrdf.graph.ObjectNode object)
Determine if the object contains the given relationship, assumes pid as the subject.

Specified by:
hasRelationship in interface DOReader
Parameters:
predicate - Predicate of the relationship, or null if unspecified (will match any).
object - Object (target) of the relationship, or null if unspecified (will match any).
Returns:
true if the object

getRelationships

public Set<RelationshipTuple> getRelationships(org.jrdf.graph.SubjectNode subject,
                                               org.jrdf.graph.PredicateNode predicate,
                                               org.jrdf.graph.ObjectNode object)
Get all matching RELS-EXT and RELS-INT relationships in the object.

Specified by:
getRelationships in interface DOReader
Parameters:
subject - Subject of the relationship, or null if unspecified (will match any).
predicate - Predicate of the relationship, or null if unspecified (will match any).
object - Object (target) of the relationship, or null if unspecified (will match any).
Returns:
All matching relationships in the object

getRelationships

public Set<RelationshipTuple> getRelationships(org.jrdf.graph.PredicateNode predicate,
                                               org.jrdf.graph.ObjectNode object)
Get all matching RELS-EXT relationships in the object, assumes pid is the subject

Specified by:
getRelationships in interface DOReader
Parameters:
predicate - Predicate of the relationship, or null if unspecified (will match any).
object - Object (target) of the relationship, or null if unspecified (will match any).
Returns:
All matching relationships in the object

getRelationships

public Set<RelationshipTuple> getRelationships()
Get all RELS-EXT and RELS-INT relationships in the object.

Specified by:
getRelationships in interface DOReader
Returns:
All RELS-EXT and RELS-INT relationships in the object


Copyright © 2012 DuraSpace. All Rights Reserved.