org.dspace.app.oai
Class DSpaceOAICatalog

java.lang.Object
  extended by ORG.oclc.oai.server.catalog.AbstractCatalog
      extended by org.dspace.app.oai.DSpaceOAICatalog

public class DSpaceOAICatalog
extends ORG.oclc.oai.server.catalog.AbstractCatalog

This is class extends OAICat's AbstractCatalog base class to allow metadata harvesting of the metadata in DSpace via OAI-PMH 2.0. FIXME: Some CNRI Handle-specific stuff in here. Anyone wanting to use something else will need to update this code too. Sorry about that.

Version:
$Revision$
Author:
Robert Tansley

Field Summary
static String OAI_ID_PREFIX
          Prefix that all our OAI identifiers have
 
Constructor Summary
DSpaceOAICatalog(Properties properties)
           
 
Method Summary
 void close()
          close the repository
 String getRecord(String identifier, String metadataPrefix)
          Retrieve the specified metadata for the specified identifier
 Vector getSchemaLocations(String identifier)
          Retrieve a list of schemaLocation values associated with the specified identifier.
 Map listIdentifiers(String resumptionToken)
          Retrieve the next set of identifiers associated with the resumptionToken
 Map listIdentifiers(String from, String until, String set, String metadataPrefix)
          Retrieve a list of identifiers that satisfy the specified criteria
 Map listRecords(String resumptionToken)
          Retrieve the next set of records associated with the resumptionToken
 Map listRecords(String from, String until, String set, String metadataPrefix)
          Retrieve a list of records that satisfy the specified criteria.
 Map listSets()
          Retrieve a list of sets that satisfy the specified criteria
 Map listSets(String resumptionToken)
          Retrieve the next set of sets associated with the resumptionToken
 
Methods inherited from class ORG.oclc.oai.server.catalog.AbstractCatalog
factory, getCrosswalks, getDescriptions, getMetadata, getMillisecondsToLive, getRecordFactory, getResumptionMap, getResumptionMap, isHarvestable, setHarvestable, setRecordFactory, setSupportedGranularityOffset, toFinestFrom, toFinestUntil
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

OAI_ID_PREFIX

public static final String OAI_ID_PREFIX
Prefix that all our OAI identifiers have

Constructor Detail

DSpaceOAICatalog

public DSpaceOAICatalog(Properties properties)
Method Detail

getSchemaLocations

public Vector getSchemaLocations(String identifier)
                          throws ORG.oclc.oai.server.verb.OAIInternalServerError,
                                 ORG.oclc.oai.server.verb.IdDoesNotExistException,
                                 ORG.oclc.oai.server.verb.NoMetadataFormatsException
Retrieve a list of schemaLocation values associated with the specified identifier.

Specified by:
getSchemaLocations in class ORG.oclc.oai.server.catalog.AbstractCatalog
Parameters:
identifier - the OAI identifier
Returns:
a Vector containing schemaLocation Strings
Throws:
ORG.oclc.oai.server.verb.OAIInternalServerError - signals an http status code 500 problem
ORG.oclc.oai.server.verb.IdDoesNotExistException - the specified identifier can't be found
ORG.oclc.oai.server.verb.NoMetadataFormatsException - the specified identifier was found but the item is flagged as deleted and thus no schemaLocations (i.e. metadataFormats) can be produced.

listIdentifiers

public Map listIdentifiers(String from,
                           String until,
                           String set,
                           String metadataPrefix)
                    throws ORG.oclc.oai.server.verb.OAIInternalServerError,
                           ORG.oclc.oai.server.verb.NoSetHierarchyException,
                           ORG.oclc.oai.server.verb.NoItemsMatchException,
                           ORG.oclc.oai.server.verb.CannotDisseminateFormatException,
                           ORG.oclc.oai.server.verb.BadArgumentException
Retrieve a list of identifiers that satisfy the specified criteria

Specified by:
listIdentifiers in class ORG.oclc.oai.server.catalog.AbstractCatalog
Parameters:
from - beginning date using the proper granularity
until - ending date using the proper granularity
set - the set name or null if no such limit is requested
metadataPrefix - the OAI metadataPrefix or null if no such limit is requested
Returns:
a Map object containing entries for "headers" and "identifiers" Iterators (both containing Strings) as well as an optional "resumptionMap" Map. It may seem strange for the map to include both "headers" and "identifiers" since the identifiers can be obtained from the headers. This may be true, but AbstractCatalog.listRecords() can operate quicker if it doesn't need to parse identifiers from the XML headers itself. Better still, do like I do below and override AbstractCatalog.listRecords(). AbstractCatalog.listRecords() is relatively inefficient because given the list of identifiers, it must call getRecord() individually for each as it constructs its response. It's much more efficient to construct the entire response in one fell swoop by overriding listRecords() as I've done here.
Throws:
ORG.oclc.oai.server.verb.OAIInternalServerError - signals an http status code 500 problem
ORG.oclc.oai.server.verb.NoSetHierarchyException - the repository doesn't support sets.
ORG.oclc.oai.server.verb.CannotDisseminateFormatException - the metadata format specified is not supported by your repository.
ORG.oclc.oai.server.verb.NoItemsMatchException
ORG.oclc.oai.server.verb.BadArgumentException

listIdentifiers

public Map listIdentifiers(String resumptionToken)
                    throws ORG.oclc.oai.server.verb.BadResumptionTokenException,
                           ORG.oclc.oai.server.verb.OAIInternalServerError
Retrieve the next set of identifiers associated with the resumptionToken

Specified by:
listIdentifiers in class ORG.oclc.oai.server.catalog.AbstractCatalog
Parameters:
resumptionToken - implementation-dependent format taken from the previous listIdentifiers() Map result.
Returns:
a Map object containing entries for "headers" and "identifiers" Iterators (both containing Strings) as well as an optional "resumptionMap" Map.
Throws:
ORG.oclc.oai.server.verb.BadResumptionTokenException - the value of the resumptionToken is invalid or expired.
ORG.oclc.oai.server.verb.OAIInternalServerError - signals an http status code 500 problem

getRecord

public String getRecord(String identifier,
                        String metadataPrefix)
                 throws ORG.oclc.oai.server.verb.OAIInternalServerError,
                        ORG.oclc.oai.server.verb.CannotDisseminateFormatException,
                        ORG.oclc.oai.server.verb.IdDoesNotExistException
Retrieve the specified metadata for the specified identifier

Specified by:
getRecord in class ORG.oclc.oai.server.catalog.AbstractCatalog
Parameters:
identifier - the OAI identifier
metadataPrefix - the OAI metadataPrefix
Returns:
the portion of the XML response.
Throws:
ORG.oclc.oai.server.verb.OAIInternalServerError - signals an http status code 500 problem
ORG.oclc.oai.server.verb.CannotDisseminateFormatException - the metadataPrefix is not supported by the item.
ORG.oclc.oai.server.verb.IdDoesNotExistException - the identifier wasn't found

listRecords

public Map listRecords(String from,
                       String until,
                       String set,
                       String metadataPrefix)
                throws ORG.oclc.oai.server.verb.OAIInternalServerError,
                       ORG.oclc.oai.server.verb.NoSetHierarchyException,
                       ORG.oclc.oai.server.verb.CannotDisseminateFormatException,
                       ORG.oclc.oai.server.verb.NoItemsMatchException,
                       ORG.oclc.oai.server.verb.BadArgumentException
Retrieve a list of records that satisfy the specified criteria. Note, though, that unlike the other OAI verb type methods implemented here, both of the listRecords methods are already implemented in AbstractCatalog rather than abstracted. This is because it is possible to implement ListRecords as a combination of ListIdentifiers and GetRecord combinations. Nevertheless, I suggest that you override both the AbstractCatalog.listRecords methods here since it will probably improve the performance if you create the response in one fell swoop rather than construct it one GetRecord at a time.

Overrides:
listRecords in class ORG.oclc.oai.server.catalog.AbstractCatalog
Parameters:
from - beginning date using the proper granularity
until - ending date using the proper granularity
set - the set name or null if no such limit is requested
metadataPrefix - the OAI metadataPrefix or null if no such limit is requested
Returns:
a Map object containing entries for a "records" Iterator object (containing XML Strings) and an optional "resumptionMap" Map.
Throws:
ORG.oclc.oai.server.verb.OAIInternalServerError - signals an http status code 500 problem
ORG.oclc.oai.server.verb.NoSetHierarchyException - The repository doesn't support sets.
ORG.oclc.oai.server.verb.CannotDisseminateFormatException - the metadataPrefix isn't supported by the item.
ORG.oclc.oai.server.verb.NoItemsMatchException
ORG.oclc.oai.server.verb.BadArgumentException

listRecords

public Map listRecords(String resumptionToken)
                throws ORG.oclc.oai.server.verb.BadResumptionTokenException,
                       ORG.oclc.oai.server.verb.OAIInternalServerError
Retrieve the next set of records associated with the resumptionToken

Overrides:
listRecords in class ORG.oclc.oai.server.catalog.AbstractCatalog
Parameters:
resumptionToken - implementation-dependent format taken from the previous listRecords() Map result.
Returns:
a Map object containing entries for "headers" and "identifiers" Iterators (both containing Strings) as well as an optional "resumptionMap" Map.
Throws:
ORG.oclc.oai.server.verb.OAIInternalServerError - signals an http status code 500 problem
ORG.oclc.oai.server.verb.BadResumptionTokenException - the value of the resumptionToken argument is invalid or expired.

listSets

public Map listSets()
             throws ORG.oclc.oai.server.verb.NoSetHierarchyException,
                    ORG.oclc.oai.server.verb.OAIInternalServerError
Retrieve a list of sets that satisfy the specified criteria

Specified by:
listSets in class ORG.oclc.oai.server.catalog.AbstractCatalog
Returns:
a Map object containing "sets" Iterator object (contains XML Strings) as well as an optional resumptionMap Map.
Throws:
ORG.oclc.oai.server.verb.NoSetHierarchyException - signals an http status code 400 problem
ORG.oclc.oai.server.verb.OAIInternalServerError - signals an http status code 500 problem

listSets

public Map listSets(String resumptionToken)
             throws ORG.oclc.oai.server.verb.BadResumptionTokenException,
                    ORG.oclc.oai.server.verb.OAIInternalServerError
Retrieve the next set of sets associated with the resumptionToken

Specified by:
listSets in class ORG.oclc.oai.server.catalog.AbstractCatalog
Parameters:
resumptionToken - implementation-dependent format taken from the previous listSets() Map result.
Returns:
a Map object containing "sets" Iterator object (contains XML Strings) as well as an optional resumptionMap Map.
Throws:
ORG.oclc.oai.server.verb.BadResumptionTokenException - the value of the resumptionToken is invalid or expired.
ORG.oclc.oai.server.verb.OAIInternalServerError - signals an http status code 500 problem

close

public void close()
close the repository

Specified by:
close in class ORG.oclc.oai.server.catalog.AbstractCatalog


Copyright © 2013 DuraSpace. All Rights Reserved.