NAME Dancer::Plugin::Catmandu::OAI - OAI-PMH provider backed by a searchable Catmandu::Store SYNOPSIS #!/usr/bin/env perl use Dancer; use Catmandu; use Dancer::Plugin::Catmandu::OAI; Catmandu->load; Catmandu->config; my $options = {}; oai_provider '/oai' , %$options; dance; DESCRIPTION Dancer::Plugin::Catmandu::OAI is a Dancer plugin to provide OAI-PMH services for Catmandu::Store-s that support CQL (such as Catmandu::Store::ElasticSearch). Follow the installation steps below to setup your own OAI-PMH server. REQUIREMENTS In the examples below an ElasticSearch 1.7.2 https://www.elastic.co/downloads/past-releases/elasticsearch-1-7-2 server will be used. Follow the instructions below for a demonstration installation: $ cpanm Dancer Catmandu::OAI Catmandu::Store::ElasticSearch $ wget https://download.elastic.co/elasticsearch/elasticsearch/elasticsearch-1.7.2.zip $ unzip elasticsearch-1.7.2.zip $ cd elasticsearch-1.7.2 $ bin/elasticsearch RECORDS Records stored in the Catmandu::Store can be in any format. Preferably the format should be easy to convert into the mandatory OAI-DC format. At a minimum each record contains an identifier '_id' and a field containing a datestamp. $ cat sample.yml --- _id: oai:my.server.org:123456 datestamp: 2016-05-17T13:37:18Z creator: - Musterman, Max - Jansen, Jan - Svenson, Sven title: - Test record ... CATMANDU CONFIGURATION ElasticSearch requires a configuration file to map record fields to CQL terms. Below is a minimal configuration required to query for identifiers and datastamps in the ElasticSearch collection: $ cat catmandu.yml --- store: oai: package: ElasticSearch options: index_name: oai bags: data: cql_mapping: default_index: basic indexes: _id: op: 'any': true 'all': true '=': true 'exact': true field: '_id' datestamp: op: '=': true '<': true '<=': true '>=': true '>': true 'exact': true field: 'datestamp' index_mappings: publication: properties: datestamp: {type: date, format: date_time_no_millis} IMPORT RECORDS With the Catmandu configuration files in place records can be imported with the catmandu command: # Drop the existing ElasticSearch 'oai' collection $ catmandu drop oai # Import the sample record $ catmandu import YAML to oai < sample.yml # Test if the records are available in the 'oai' collection $ catmandu export oai DANCER CONFIGURATION The Dancer configuration file 'config.yml' contains basic information for the OAI-PMH plugin to work: * store - In which Catmandu::Store are the metadata records stored * bag - In which Catmandu::Bag are the records of this 'store' (use: 'data' as default) * datestamp_field - Which field in the record contains a datestamp ('datestamp' in our example above) * repositoryName - The name of the repository * uri_base - The full base url of the OAI controller. To be used when behind a proxy server. When not set, this module relies on the Dancer request to provide its full url. Use middleware like 'ReverseProxy' or 'Dancer::Middleware::Rebase' in that case. * adminEmail - An administrative email. Can be string or array of strings. This will be included in the Identify response. * compression - a compression encoding supported by the repository. Can be string or array of strings. This will be included in the Identify response. * description - XML container that describes your repository. Can be string or array of strings. This will be included in the Identify response. Note that this module will try to validate the XML data. * earliestDatestamp - The earliest datestamp available in the dataset as YYYY-MM-DDTHH:MM:SSZ. This will be determined dynamically if no static value is given. * deletedRecord - The policy for deleted records. See also: L * repositoryIdentifier - A prefix to use in OAI-PMH identifiers * cql_filter - A CQL query to find all records in the database that should be made available to OAI-PMH * default_search_params - set default arguments that get passed to every call to the bag's search method * search_strategy - default is C, set to C to avoid deep paging (Elasticsearch only) * limit - The maximum number of records to be returned in each OAI-PMH request * delimiter - Delimiters used in prefixing a record identifier with a repositoryIdentifier (use: ':' as default) * sampleIdentifier - A sample identifier * metadata_formats - An array of metadataFormats that are supported * metadataPrefix - A short string for the name of the format * schema - An URL to the XSD schema of this format * metadataNamespace - A XML namespace for this format * template - The path to a Template Toolkit file to transform your records into this format * fix - Optionally an array of one or more L-es or Fix files * sets - Optional an array of OAI-PMH sets and the CQL query to retrieve records in this set from the Catmandu::Store * setSpec - A short string for the same of the set * setName - A longer description of the set * setDescription - an optional and repeatable container that may hold community-specific XML-encoded data about the set. Should be string or array of strings. * cql - The CQL command to find records in this set in the L * xsl_stylesheet - Optional path to an xsl stylesheet * template_options - An optional hash of configuration options that will be passed to L or L