proai.service
Class Responder

java.lang.Object
  extended by proai.service.Responder

public class Responder
extends java.lang.Object

Provides transport-neutral responses to OAI-PMH requests.

A single Responder instance handles multiple concurrent OAI-PMH requests and provides responses without regard to the transport protocol.

Responses are provided via ResponseData objects that can write their XML to a given PrintWriter. The XML provided does not include an XML declaration or an OAI-PMH response header -- this is the responsibility of higher-level application code.

At this level, errors are signaled by exceptions. Serializing them for transport is the responsibility of higher-level application code.

Author:
Chris Wilper

Field Summary
static java.lang.String ERR_BAD_FORMAT_FOR_ITEM
           
static java.lang.String ERR_DATE_FORMAT
           
static java.lang.String ERR_FROM_UNTIL
           
static java.lang.String ERR_ITEM_DOESNT_EXIST
           
static java.lang.String ERR_MISSING_IDENTIFIER
           
static java.lang.String ERR_MISSING_PREFIX
           
static java.lang.String ERR_NO_FORMATS_FOR_ITEM
           
static java.lang.String ERR_NO_RECORDS_MATCH
           
static java.lang.String ERR_NO_SET_HIERARCHY
           
static java.lang.String ERR_NO_SUCH_FORMAT
           
static java.lang.String ERR_RESUMPTION_EXCLUSIVE
           
static java.lang.String PROP_INCOMPLETEIDENTIFIERLISTSIZE
           
static java.lang.String PROP_INCOMPLETERECORDLISTSIZE
           
static java.lang.String PROP_INCOMPLETESETLISTSIZE
           
 
Constructor Summary
Responder(java.util.Properties props)
           
Responder(RecordCache cache, SessionManager sessionManager, int incompleteIdentifierListSize, int incompleteRecordListSize, int incompleteSetListSize)
           
 
Method Summary
 void close()
          Release any resources held by the session manager and the cache.
 ResponseData getRecord(java.lang.String identifier, java.lang.String metadataPrefix)
          Get the response for a GetRecord request.
 ResponseData identify()
          Get the response for an Identify request.
 ResponseData listIdentifiers(java.lang.String from, java.lang.String until, java.lang.String metadataPrefix, java.lang.String set, java.lang.String resumptionToken)
          Get the response for a ListIdentifiers request.
 ResponseData listMetadataFormats(java.lang.String identifier)
          Get the response for a ListMetadataFormats request.
 ResponseData listRecords(java.lang.String from, java.lang.String until, java.lang.String metadataPrefix, java.lang.String set, java.lang.String resumptionToken)
          Get the response for a ListRecords request.
 ResponseData listSets(java.lang.String resumptionToken)
          Get the response for a ListSets request.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

PROP_INCOMPLETESETLISTSIZE

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

PROP_INCOMPLETERECORDLISTSIZE

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

PROP_INCOMPLETEIDENTIFIERLISTSIZE

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

ERR_MISSING_IDENTIFIER

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

ERR_MISSING_PREFIX

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

ERR_ITEM_DOESNT_EXIST

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

ERR_BAD_FORMAT_FOR_ITEM

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

ERR_NO_FORMATS_FOR_ITEM

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

ERR_NO_SET_HIERARCHY

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

ERR_RESUMPTION_EXCLUSIVE

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

ERR_DATE_FORMAT

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

ERR_FROM_UNTIL

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

ERR_NO_SUCH_FORMAT

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

ERR_NO_RECORDS_MATCH

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

Responder

public Responder(java.util.Properties props)
          throws ServerException
Throws:
ServerException

Responder

public Responder(RecordCache cache,
                 SessionManager sessionManager,
                 int incompleteIdentifierListSize,
                 int incompleteRecordListSize,
                 int incompleteSetListSize)
          throws ServerException
Throws:
ServerException
Method Detail

getRecord

public ResponseData getRecord(java.lang.String identifier,
                              java.lang.String metadataPrefix)
                       throws BadArgumentException,
                              CannotDisseminateFormatException,
                              IdDoesNotExistException,
                              ServerException
Get the response for a GetRecord request.

Parameters:
identifier - the item identifier.
metadataPrefix - the format of the record (oai_dc, etc).
Throws:
BadArgumentException - if either of the required parameters are null.
CannotDisseminateFormatException - if the value of the metadataPrefix argument is not supported by the item identified by the value of the identifier argument.
IdDoesNotExistException - if the value of the identifier argument is unknown or illegal in this repository.
ServerException - if a low-level (non-protocol) error occurred.

identify

public ResponseData identify()
                      throws ServerException
Get the response for an Identify request.

Throws:
ServerException - if a low-level (non-protocol) error occurred.

listIdentifiers

public ResponseData listIdentifiers(java.lang.String from,
                                    java.lang.String until,
                                    java.lang.String metadataPrefix,
                                    java.lang.String set,
                                    java.lang.String resumptionToken)
                             throws BadArgumentException,
                                    BadResumptionTokenException,
                                    CannotDisseminateFormatException,
                                    NoRecordsMatchException,
                                    NoSetHierarchyException,
                                    ServerException
Get the response for a ListIdentifiers request.

Parameters:
from - optional UTC date specifying a lower bound for datestamp-based selective harvesting.
until - optional UTC date specifying an upper bound for datestamp-based selective harvesting.
metadataPrefix - specifies that headers should be returned only if the metadata format matching the supplied metadataPrefix is available (or has been deleted).
set - optional argument with a setSpec value, which specifies set criteria for selective harvesting.
resumptionToken - exclusive argument with a value that is the flow control token returned by a previous ListIdentifiers request that issued an incomplete list.
Throws:
BadArgumentException - if resumptionToken is specified with any other parameters, or if resumptionToken is unspecified and any required parameters are not.
BadResumptionTokenException - if the value of the resumptionToken argument is invalid or expired.
CannotDisseminateFormatException - if the value of the metadataPrefix argument is not supported by the repository.
NoRecordsMatchException - if the combination of the values of the from, until, and set arguments results in an empty list.
NoSetHierarchyException - if set is specified and the repository does not support sets.
ServerException - if a low-level (non-protocol) error occurred.

listMetadataFormats

public ResponseData listMetadataFormats(java.lang.String identifier)
                                 throws IdDoesNotExistException,
                                        NoMetadataFormatsException,
                                        ServerException
Get the response for a ListMetadataFormats request.

Parameters:
identifier - an optional argument that specifies the unique identifier of the item for which available metadata formats are being requested. If this argument is omitted, then the response includes all metadata formats supported by this repository.
Throws:
IdDoesNotExistException - if the value of the identifier argument is unknown or illegal in this repository.
NoMetadataFormats - there are no metadata formats available for the specified item.
ServerException - if a low-level (non-protocol) error occurred.
NoMetadataFormatsException

listRecords

public ResponseData listRecords(java.lang.String from,
                                java.lang.String until,
                                java.lang.String metadataPrefix,
                                java.lang.String set,
                                java.lang.String resumptionToken)
                         throws BadArgumentException,
                                BadResumptionTokenException,
                                CannotDisseminateFormatException,
                                NoRecordsMatchException,
                                NoSetHierarchyException,
                                ServerException
Get the response for a ListRecords request.

Parameters:
from - optional UTC date specifying a lower bound for datestamp-based selective harvesting.
until - optional UTC date specifying an upper bound for datestamp-based selective harvesting.
metadataPrefix - specifies that records should be returned only if the metadata format matching the supplied metadataPrefix is available (or has been deleted).
set - optional argument with a setSpec value, which specifies set criteria for selective harvesting.
resumptionToken - exclusive argument with a value that is the flow control token returned by a previous ListIdentifiers request that issued an incomplete list.
Throws:
BadArgumentException - if resumptionToken is specified with any other parameters, or if resumptionToken is unspecified and any required parameters are not.
BadResumptionTokenException - if the value of the resumptionToken argument is invalid or expired.
CannotDisseminateFormatException - if the value of the metadataPrefix argument is not supported by the repository.
NoRecordsMatchException - if the combination of the values of the from, until, and set arguments results in an empty list.
NoSetHierarchyException - if set is specified and the repository does not support sets.
ServerException - if a low-level (non-protocol) error occurred.

listSets

public ResponseData listSets(java.lang.String resumptionToken)
                      throws BadResumptionTokenException,
                             NoSetHierarchyException,
                             ServerException
Get the response for a ListSets request.

Parameters:
resumptionToken - exclusive argument with a value that is the flow control token returned by a previous ListSets request that issued an incomplete list.
Throws:
BadResumptionTokenException - if the value of the resumptionToken argument is invalid or expired.
NoSetHierarchyException - if the repository does not support sets.
ServerException - if a low-level (non-protocol) error occurred.

close

public void close()
           throws ServerException
Release any resources held by the session manager and the cache.

Throws:
ServerException