OAI-PMH for koha

This file is an implementation of the OAI-PMH protocol for koha. Its purpose is to share metadata in Dublin core format with harvester like PKP-Harverster. Presently, all the bibliographic records managed by the runing koha instance are publicly shared (as the opac is).

Package MARC::Record::KOHADC

This package is a sub-class of the MARC::File::USMARC. It add methods and functions to map the content of a marc record (of any flavor) to Dublin core. As soon as it is possible, mapping between marc fields and there semantic are got from ::GetMarcFromKohaField fonction from C4::Biblio (see also the "Koha to MARC mapping" preferences).

The OAI::KOHA package

This package is a subclass of the OAI::DC data provider. It overides needed methods and provide the links between the OAI-PMH request and the koha application. The data used in answers are from the koha table bibio.


return the Set list to the verb=ListSets query. Data are from the 'OAI-PMH:Set' preference.


The new method is the constructor for this class. It doesn't have any parameters and get required data from koha preferences. Koha LibraryName is used to identify the OAI-PMH repository, OAI-PMH:MaxCount is used to set the maximun number of records returned at the same time in answers to verb=ListRecords or verb=ListIdentifiers queries.

The method return a blessed reference.


The dispose method is used as a destructor. It call just the SUPER::dispose method.

buildResumptionToken and parseResumptionToken

Theses two functions are used to manage resumption tokens. The choosed syntax is simple as possible, a token is only the metadata prefix, the offset in the full answer, the from and the until date (in the yyyy-mm-dd format) joined by ':' caracter.

buildResumptionToken get the four elements as parameters and return the ':' separated string.

parseResumptionToken is used to set the default values to the from and until date, the metadata prefix using the resumption tocken if necessary. This function have four parameters (from,until,metadata prefix and resumption tocken) which can be undefined and return every time this list of values correctly set. The missing values are set with defaults: offset=0, from= 1970-01-01 and until is set to current date.


return the full list Set to the verb=ListSets query. Data are from the 'OAI-PMH:Set' preference.


This method select the record specified as its first parameter from the koha biblio table and return a reference to a MARC::Record::KOHADC object.


This method return a list of 'MaxCount' references to MARC::Record::KOHADC object build from the koha biblio table according to its parameters : set, from and until date, metadata prefix and resumption token.

Main package

The main function is the starting point of the service. The first step is to verify if the service is enable using the 'OAI-PMH' preference value (See Koha systeme preferences).

If the service is enable, it create a new instance of the OAI::KOHA data provider (see before) and run the service.