proai.driver.impl
Class OAIDriverImpl

java.lang.Object
  extended by proai.driver.impl.OAIDriverImpl
All Implemented Interfaces:
OAIDriver, Writable

public class OAIDriverImpl
extends java.lang.Object
implements OAIDriver

An simple OAIDriver for testing/demonstration purposes. The directory should contain the following files: identity.xml records/ item1-oai_dc-2005-01-01T08-50-44.xml sets/ abovetwo.xml abovetwo-even.xml abovetwo-odd.xml prime.xml formats/ oai_dc.txt line1: ns line2: loc


Field Summary
static java.lang.String BASE_DIR_PROPERTY
           
static java.lang.String FORMATS_DIRNAME
           
static java.lang.String IDENTITY_FILENAME
           
static java.lang.String RECORDS_DIRNAME
           
static java.lang.String SETS_DIRNAME
           
 
Constructor Summary
OAIDriverImpl()
           
OAIDriverImpl(java.io.File dir)
           
 
Method Summary
 void close()
          Release any resources held by the driver.
 java.util.Date getLatestDate()
          Get the latest date that something changed in the remote repository.
 void init(java.util.Properties props)
          Initialize from properties.
 RemoteIterator<MetadataFormat> listMetadataFormats()
          Get an iterator over a list of MetadataFormat objects representing all OAI metadata formats currently supported by the repository.
 RemoteIterator<Record> listRecords(java.util.Date from, java.util.Date until, java.lang.String mdPrefix)
          Get an iterator of Record objects representing all records in the format indicated by mdPrefix, which have changed in the given date range.
 RemoteIterator<SetInfo> listSetInfo()
          Get an iterator over a list of SetInfo objects representing all OAI sets currently supported by the repository.
 void write(java.io.PrintWriter out)
          Write information about the repository to the given PrintWriter.
static void writeFromFile(java.io.File file, java.io.PrintWriter out)
           
 void writeRecordXML(java.lang.String itemID, java.lang.String mdPrefix, java.lang.String sourceInfo, java.io.PrintWriter writer)
          Write the XML of the record whose source info is given.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

BASE_DIR_PROPERTY

public static final java.lang.String BASE_DIR_PROPERTY
See Also:
Constant Field Values

IDENTITY_FILENAME

public static final java.lang.String IDENTITY_FILENAME
See Also:
Constant Field Values

RECORDS_DIRNAME

public static final java.lang.String RECORDS_DIRNAME
See Also:
Constant Field Values

SETS_DIRNAME

public static final java.lang.String SETS_DIRNAME
See Also:
Constant Field Values

FORMATS_DIRNAME

public static final java.lang.String FORMATS_DIRNAME
See Also:
Constant Field Values
Constructor Detail

OAIDriverImpl

public OAIDriverImpl()

OAIDriverImpl

public OAIDriverImpl(java.io.File dir)
              throws RepositoryException
Throws:
RepositoryException
Method Detail

init

public void init(java.util.Properties props)
          throws RepositoryException
Description copied from interface: OAIDriver
Initialize from properties.

Specified by:
init in interface OAIDriver
Parameters:
props - the implementation-specific initialization properties.
Throws:
RepositoryException - if required properties are missing/bad, or initialization failed for any reason.

write

public void write(java.io.PrintWriter out)
           throws RepositoryException
Description copied from interface: OAIDriver
Write information about the repository to the given PrintWriter.

This will be a well-formed XML chunk beginning with an Identify element, as described in section 4.2 of the OAI-PMH 2.0 specification.

Specified by:
write in interface OAIDriver
Specified by:
write in interface Writable
Throws:
RepositoryException - if there is a problem reading from the repository.

getLatestDate

public java.util.Date getLatestDate()
Description copied from interface: OAIDriver
Get the latest date that something changed in the remote repository.

If this is greater than the previously-aquired latestDate, the formats, setInfos, and identity will be retrieved again, and it will be used as the "until" date for the next record query.

Specified by:
getLatestDate in interface OAIDriver

listMetadataFormats

public RemoteIterator<MetadataFormat> listMetadataFormats()
Description copied from interface: OAIDriver
Get an iterator over a list of MetadataFormat objects representing all OAI metadata formats currently supported by the repository.

Specified by:
listMetadataFormats in interface OAIDriver
See Also:
MetadataFormat

listSetInfo

public RemoteIterator<SetInfo> listSetInfo()
Description copied from interface: OAIDriver
Get an iterator over a list of SetInfo objects representing all OAI sets currently supported by the repository.

The content will be a well-formed XML chunk beginning with a set element, as described in section 4.6 of the OAI-PMH 2.0 specification.

Specified by:
listSetInfo in interface OAIDriver
See Also:
SetInfo

listRecords

public RemoteIterator<Record> listRecords(java.util.Date from,
                                          java.util.Date until,
                                          java.lang.String mdPrefix)
Description copied from interface: OAIDriver
Get an iterator of Record objects representing all records in the format indicated by mdPrefix, which have changed in the given date range.

Regarding dates: If from is not null, the date is greater than (non-inclusive) Until must be specified, and it is less than or equal to (inclusive).

Specified by:
listRecords in interface OAIDriver
See Also:
Record

writeRecordXML

public void writeRecordXML(java.lang.String itemID,
                           java.lang.String mdPrefix,
                           java.lang.String sourceInfo,
                           java.io.PrintWriter writer)
                    throws RepositoryException
Description copied from interface: OAIDriver
Write the XML of the record whose source info is given. SourceInfo MUST NOT contain newlines. Otherwise, the format is up to the implementation. The Record implementation produces these strings, and the OAIDriver implementation should know how to use them to produce the XML. The record must be a well-formed XML chunk beginning with a record element, as described in section 4.1 of the OAI-PMH 2.0 specification.

Specified by:
writeRecordXML in interface OAIDriver
Throws:
RepositoryException

close

public void close()
Description copied from interface: OAIDriver
Release any resources held by the driver.

Specified by:
close in interface OAIDriver

writeFromFile

public static void writeFromFile(java.io.File file,
                                 java.io.PrintWriter out)
                          throws RepositoryException
Throws:
RepositoryException