se.kb.oai.pmh
Class OaiPmhServer

java.lang.Object
  extended by se.kb.oai.pmh.OaiPmhServer

public class OaiPmhServer
extends Object

Class that acts as a facade for an OAI-PMH server. Has methods that corresponds to the different verbs in the OAI-PMH specification and that will return appropriate objects based on the response.

For more about the different verbs, requests and responses in the OAI-PMH specification, see http://www.openarchives.org/OAI/openarchivesprotocol.html.

Author:
Oskar Grenholm, National Library of Sweden

Constructor Summary
OaiPmhServer(String url)
          Creates an OaiPmhServer with the given base URL.
OaiPmhServer(URL url)
          Creates an OaiPmhServer with the given base URL.
 
Method Summary
 String getBaseUrl()
          Get the base URL to the OAI-PMH server.
 Record getRecord(String identifier, String metadataPrefix)
          Send a GetRecord request to the OAI-PMH server with the specified parameters.
 Identification identify()
          Send a request for the OAI-PMH server to Identify it self.
 IdentifiersList listIdentifiers(ResumptionToken resumptionToken)
          List next set of identifiers not returned in the previous response from a call to listIdentifiers().
 IdentifiersList listIdentifiers(String metadataPrefix)
          Send a request to the OAI-PMH server that it should list all identifiers that has metadata in the specified format.
 IdentifiersList listIdentifiers(String metadataPrefix, String from, String until, String set)
          Send a request to the OAI-PMH server that it should list all identifiers that matches the given parameters.
 MetadataFormatsList listMetadataFormats()
          Ask the OAI-PMH server to list all metadata formats it holds.
 MetadataFormatsList listMetadataFormats(String identifier)
          Ask the OAI-PMH server to list all metadata formats it holds for the specified identifier.
 RecordsList listRecords(ResumptionToken resumptionToken)
          List next set of records not returned in the previous response from a call to listRecords().
 RecordsList listRecords(String metadataPrefix)
          Send a request for the OAI-PMH server to return a list of Records.
 RecordsList listRecords(String metadataPrefix, String from, String until, String set)
          Send a request for the OAI-PMH server to return a list of Records.
 SetsList listSets()
          List all sets the OAI-PMH server has.
 SetsList listSets(ResumptionToken resumptionToken)
          List next set of sets not returned in the previous response from a call to listSets().
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

OaiPmhServer

public OaiPmhServer(String url)
Creates an OaiPmhServer with the given base URL.

Parameters:
url - base URL that points to an OAI-PMH server

OaiPmhServer

public OaiPmhServer(URL url)
Creates an OaiPmhServer with the given base URL.

Parameters:
url - base URL that points to an OAI-PMH server
Method Detail

getBaseUrl

public String getBaseUrl()
Get the base URL to the OAI-PMH server.

Returns:
the base URL

getRecord

public Record getRecord(String identifier,
                        String metadataPrefix)
                 throws OAIException
Send a GetRecord request to the OAI-PMH server with the specified parameters.

Parameters:
identifier - id to get a Record for
metadataPrefix - which metadata format
Returns:
the response from the server
Throws:
OAIException

identify

public Identification identify()
                        throws OAIException
Send a request for the OAI-PMH server to Identify it self.

Returns:
the response from the server
Throws:
OAIException

listIdentifiers

public IdentifiersList listIdentifiers(String metadataPrefix)
                                throws OAIException
Send a request to the OAI-PMH server that it should list all identifiers that has metadata in the specified format.

Parameters:
metadataPrefix - which metadata format
Returns:
a list of identifiers
Throws:
OAIException

listIdentifiers

public IdentifiersList listIdentifiers(String metadataPrefix,
                                       String from,
                                       String until,
                                       String set)
                                throws OAIException
Send a request to the OAI-PMH server that it should list all identifiers that matches the given parameters.

Parameters:
metadataPrefix - which metadata format
from - a start date, optional (may be null)
until - a stop date, optional (may be null)
set - a specific set, optional (may be null)
Returns:
a list of identifiers
Throws:
OAIException

listIdentifiers

public IdentifiersList listIdentifiers(ResumptionToken resumptionToken)
                                throws OAIException
List next set of identifiers not returned in the previous response from a call to listIdentifiers().

Parameters:
resumptionToken - a resumption token returned from a previous call
Returns:
a list of identifiers
Throws:
OAIException

listRecords

public RecordsList listRecords(String metadataPrefix)
                        throws OAIException
Send a request for the OAI-PMH server to return a list of Records.

Parameters:
metadataPrefix - which metadata format
Returns:
a list of records
Throws:
OAIException

listRecords

public RecordsList listRecords(String metadataPrefix,
                               String from,
                               String until,
                               String set)
                        throws OAIException
Send a request for the OAI-PMH server to return a list of Records.

Parameters:
metadataPrefix - which metadata format
from - a start date, optional (may be null)
until - a stop date, optional (may be null)
set - a specific set, optional (may be null)
Returns:
a lsit of records
Throws:
OAIException

listRecords

public RecordsList listRecords(ResumptionToken resumptionToken)
                        throws OAIException
List next set of records not returned in the previous response from a call to listRecords().

Parameters:
resumptionToken - a resumption token returned from a previous call
Returns:
a list of records
Throws:
OAIException

listMetadataFormats

public MetadataFormatsList listMetadataFormats()
                                        throws OAIException
Ask the OAI-PMH server to list all metadata formats it holds.

Returns:
a list of available metadata formats
Throws:
OAIException

listMetadataFormats

public MetadataFormatsList listMetadataFormats(String identifier)
                                        throws OAIException
Ask the OAI-PMH server to list all metadata formats it holds for the specified identifier.

Returns:
a list of available metadata formats
Throws:
OAIException

listSets

public SetsList listSets()
                  throws OAIException
List all sets the OAI-PMH server has.

Returns:
a list of sets
Throws:
OAIException

listSets

public SetsList listSets(ResumptionToken resumptionToken)
                  throws OAIException
List next set of sets not returned in the previous response from a call to listSets().

Parameters:
resumptionToken -
Returns:
a list of sets
Throws:
OAIException


Copyright © 2008. All Rights Reserved.