LP#1729620: (follow-up) move OAI methods to open-ils.supercat
authorGalen Charlton <gmc@equinoxOLI.org>
Fri, 24 Sep 2021 16:40:20 +0000 (12:40 -0400)
committerJane Sandberg <sandbergja@gmail.com>
Mon, 28 Mar 2022 02:57:21 +0000 (19:57 -0700)
A new service isn't really necessary for the handful
of methods that OAI support needs. Since SuperCat is
where other record harvesting and export methods live, what
was open-ils.oai is moved to SuperCat via this patch.

Signed-off-by: Galen Charlton <gmc@equinoxOLI.org>
Signed-off-by: Mike Rylander <mrylander@gmail.com>

Open-ILS/examples/opensrf.xml.example
Open-ILS/examples/opensrf_core.xml.example
Open-ILS/src/perlmods/lib/OpenILS/Application/SuperCat.pm
Open-ILS/src/perlmods/lib/OpenILS/Application/SuperCat/OAI.pm [moved from Open-ILS/src/perlmods/lib/OpenILS/Application/OAI.pm with 96% similarity]
Open-ILS/src/perlmods/lib/OpenILS/WWW/OAI.pm
docs/RELEASE_NOTES_NEXT/OAI2/new_oai_opensrf_service.adoc

index 7074a0d..447dca3 100644 (file)
@@ -796,6 +796,101 @@ vim:et:ts=4:sw=4:
                     <min_spare_children>1</min_spare_children>
                     <max_spare_children>5</max_spare_children>
                 </unix_config>
+                <app_settings>
+                    <oai>
+                        <!-- Where necessary, override the default settings here in the app_settings element. -->
+
+                        <!-- The OAI endpoint. The domain is the name of your proxy or frontend opac website. -->
+                        <!-- <base_url>http://mydomain.org/opac/extras/oai</base_url> -->
+
+                        <!-- <repository_name>My organization(s)</repository_name> -->
+                        <!-- <admin_email>admin@mydomain.org</admin_email> -->
+
+                        <!-- The maximum number of records in a ListRecords and ListIdentifiers response. -->
+                        <!-- <max_count>50</max_count> -->
+
+                        <!-- <granularity>YYYY-MM-DDThh:mm:ss</granularity> -->
+                        <!-- <earliest_datestamp>0001-01-01</earliest_datestamp> -->
+                        <!-- <deleted_record>yes</deleted_record> -->
+                        <!-- <scheme>oai</scheme> -->
+                        <!-- <repository_identifier>mydomain.org</repository_identifier> -->
+                        <!-- <delimiter>:</delimiter> -->
+                        <!-- <sample_identifier>oai:mydomain.org:12345</sample_identifier> -->
+                        <!-- <list_sets>false</list_sets> -->
+
+                        <!--
+                        The metadataformat element contains the schema for the oai_dc and marcxml metadata formats.
+                        Each schema needs a reference to an xslt document.
+                        You can replace them with your custom xslt stylesheets.
+                        Place those in the /<openils sysdir>/var/xsl folder.
+                        You can also extend the OAI2 service further with new metadata schema.
+
+                        Bibliographic and authority records share the same stylesheet.
+                        Should you want to render them differently, use the
+                        marc:datafield[@tag='901']/marc:subfield[@code='t']
+                        value to identify the record type. -->
+
+                        <!--
+                        <metadataformat>
+                            <oai_dc>
+                                <namespace_uri>http://www.openarchives.org/OAI/2.0/oai_dc/</namespace_uri>
+                                <schema_location>http://www.openarchives.org/OAI/2.0/oai_dc.xsd</schema_location>
+                                <xslt>OAI2_OAIDC.xsl</xslt>
+                            </oai_dc>
+                            <marcxml>
+                                <namespace_uri>http://www.loc.gov/MARC21/slim</namespace_uri>
+                                <schema_location>http://www.loc.gov/standards/marcxml/schema/MARC21slim.xsd</schema_location>
+                                <xslt>OAI2_MARC21slim.xsl</xslt>
+                            </marcxml>
+                        </metadataformat> -->
+
+                        <!--
+                        You can add different schema to the metadataformat element thus:
+                            <mods>
+                                <namespace_uri>http://www.loc.gov/mods/</namespace_uri>
+                                <schema_location>http://www.loc.gov/standards/mods/mods.xsd</schema_location>
+                                <xslt>my-custom-marc2mods.xsl</xslt>
+                            </mods>
+                            <my-metadata_prefix>
+                                <namespace_uri>my-namespace_uri</namespace_uri>
+                                <schema_location>my-schema_location</schema_location>
+                                <xslt>my-marc2my-metadata.xsl</xslt>
+                            </my-metadata_prefix>
+                        -->
+
+                        <!-- Change the way the asset copy values are mapped to which subfield codes: -->
+                        <!--
+                        <copies>
+                            <a>location</a>
+                            <b>owning_lib</b>
+                            <c>callnumber</c>
+                            <d>circlib</d>
+                            <g>barcode</g>
+                            <n>status</n>
+                        </copies>
+                        -->
+                        <!-- Or add static values to the copies element like this:
+                            <z>A value that always should for example be in the 852$z</z>
+                        -->
+
+                        <!-- Accept only 852$[barcode] values that match this regular expression. E.g.
+                        <barcode_filter>^[A-Za-z0-9]+</barcode_filter>
+                        only renders 852 datafields that contain barcodes values that begin with letters and numbers.
+                        -->
+                        <!--
+                        <barcode_filter><barcode_filter>
+                        -->
+
+                        <!-- Accept only 852$[status] values that match this regular expression. E.g.
+                        <status_filter>^Available$</status_filter>
+                        only renders 852 datafields that contain status code values that exactly match the string 'Available'.
+                        -->
+                        <!--
+                        <status_filter></status_filter>
+                        -->
+                    <oai>
+                </app_settings>
+
             </open-ils.supercat>
 
             <!-- server for accessing user info -->
@@ -991,118 +1086,6 @@ vim:et:ts=4:sw=4:
                 </app_settings>
             </open-ils.cstore>
 
-            <open-ils.oai>
-                <keepalive>5</keepalive>
-                <stateless>1</stateless>
-                <language>perl</language>
-                <implementation>OpenILS::Application::OAI</implementation>
-                <max_requests>199</max_requests>
-                <unix_config>
-                    <unix_sock>open-ils.oai_unix.sock</unix_sock>
-                    <unix_pid>open-ils.oai_unix.pid</unix_pid>
-                    <max_requests>1000</max_requests>
-                    <unix_log>open-ils.oai_unix.log</unix_log>
-                    <min_children>1</min_children>
-                    <max_children>5</max_children>
-                    <min_spare_children>1</min_spare_children>
-                    <max_spare_children>2</max_spare_children>
-                </unix_config>
-                <app_settings>
-
-                    <!-- Where necessary, override the default settings here in the app_settings element. -->
-
-                    <!-- The OAI endpoint. The domain is the name of your proxy or frontend opac website. -->
-                    <!-- <base_url>http://mydomain.org/opac/extras/oai</base_url> -->
-
-                    <!-- <repository_name>My organization(s)</repository_name> -->
-                    <!-- <admin_email>admin@mydomain.org</admin_email> -->
-
-                    <!-- The maximum number of records in a ListRecords and ListIdentifiers response. -->
-                    <!-- <max_count>50</max_count> -->
-
-                    <!-- <granularity>YYYY-MM-DDThh:mm:ss</granularity> -->
-                    <!-- <earliest_datestamp>0001-01-01</earliest_datestamp> -->
-                    <!-- <deleted_record>yes</deleted_record> -->
-                    <!-- <scheme>oai</scheme> -->
-                    <!-- <repository_identifier>mydomain.org</repository_identifier> -->
-                    <!-- <delimiter>:</delimiter> -->
-                    <!-- <sample_identifier>oai:mydomain.org:12345</sample_identifier> -->
-                    <!-- <list_sets>false</list_sets> -->
-
-                    <!--
-                    The metadataformat element contains the schema for the oai_dc and marcxml metadata formats.
-                    Each schema needs a reference to an xslt document.
-                    You can replace them with your custom xslt stylesheets.
-                    Place those in the /<openils sysdir>/var/xsl folder.
-                    You can also extend the OAI2 service further with new metadata schema.
-
-                    Bibliographic and authority records share the same stylesheet.
-                    Should you want to render them differently, use the
-                    marc:datafield[@tag='901']/marc:subfield[@code='t']
-                    value to identify the record type. -->
-
-                    <!--
-                    <metadataformat>
-                        <oai_dc>
-                            <namespace_uri>http://www.openarchives.org/OAI/2.0/oai_dc/</namespace_uri>
-                            <schema_location>http://www.openarchives.org/OAI/2.0/oai_dc.xsd</schema_location>
-                            <xslt>OAI2_OAIDC.xsl</xslt>
-                        </oai_dc>
-                        <marcxml>
-                            <namespace_uri>http://www.loc.gov/MARC21/slim</namespace_uri>
-                            <schema_location>http://www.loc.gov/standards/marcxml/schema/MARC21slim.xsd</schema_location>
-                            <xslt>OAI2_MARC21slim.xsl</xslt>
-                        </marcxml>
-                    </metadataformat> -->
-
-                    <!--
-                    You can add different schema to the metadataformat element thus:
-                        <mods>
-                            <namespace_uri>http://www.loc.gov/mods/</namespace_uri>
-                            <schema_location>http://www.loc.gov/standards/mods/mods.xsd</schema_location>
-                            <xslt>my-custom-marc2mods.xsl</xslt>
-                        </mods>
-                        <my-metadata_prefix>
-                            <namespace_uri>my-namespace_uri</namespace_uri>
-                            <schema_location>my-schema_location</schema_location>
-                            <xslt>my-marc2my-metadata.xsl</xslt>
-                        </my-metadata_prefix>
-                    -->
-
-                    <!-- Change the way the asset copy values are mapped to which subfield codes: -->
-                    <!--
-                    <copies>
-                        <a>location</a>
-                        <b>owning_lib</b>
-                        <c>callnumber</c>
-                        <d>circlib</d>
-                        <g>barcode</g>
-                        <n>status</n>
-                    </copies>
-                    -->
-                    <!-- Or add static values to the copies element like this:
-                        <z>A value that always should for example be in the 852$z</z>
-                    -->
-
-                    <!-- Accept only 852$[barcode] values that match this regular expression. E.g.
-                    <barcode_filter>^[A-Za-z0-9]+</barcode_filter>
-                    only renders 852 datafields that contain barcodes values that begin with letters and numbers.
-                    -->
-                    <!--
-                    <barcode_filter><barcode_filter>
-                    -->
-
-                    <!-- Accept only 852$[status] values that match this regular expression. E.g.
-                    <status_filter>^Available$</status_filter>
-                    only renders 852 datafields that contain status code values that exactly match the string 'Available'.
-                    -->
-                    <!--
-                    <status_filter></status_filter>
-                    -->
-
-                </app_settings>
-            </open-ils.oai>
-
             <open-ils.pcrud>
                 <keepalive>6</keepalive>
                 <migratable>1</migratable>
@@ -1477,13 +1460,11 @@ vim:et:ts=4:sw=4:
                 <appname>open-ils.justintime</appname>  
                 <appname>open-ils.cstore</appname>  
                 <appname>open-ils.collections</appname>
-                <appname>open-ils.oai</appname>
                 <appname>open-ils.qstore</appname>
                 <appname>open-ils.reporter</appname>  
                 <appname>open-ils.reporter-store</appname>  
                 <!-- <appname>open-ils.resolver</appname> -->
                 <appname>open-ils.permacrud</appname>  
-                <appname>open-ils.oai</appname>  
                 <appname>open-ils.pcrud</appname>  
                 <appname>open-ils.trigger</appname>  
                 <appname>open-ils.url_verify</appname>
index 1a09e9e..aeba4ad 100644 (file)
@@ -30,7 +30,6 @@ Example OpenSRF bootstrap configuration file for Evergreen
           <service>open-ils.courses</service>
           <service>open-ils.curbside</service>
           <service>open-ils.fielder</service>
-          <service>open-ils.oai</service>
           <service>open-ils.pcrud</service>
           <service>open-ils.permacrud</service>
           <service>open-ils.reporter</service>
index edaa48c..8aac6ab 100644 (file)
@@ -6,6 +6,8 @@ use Unicode::Normalize;
 # ... and this has some handy common methods
 use OpenILS::Application::AppUtils;
 
+use OpenILS::Application::SuperCat::OAI;
+
 my $parser = new XML::LibXML;
 my $U = 'OpenILS::Application::AppUtils';
 
@@ -182,6 +184,8 @@ sub child_init {
 
     register_new_authorities_methods();
 
+    OpenILS::Application::SuperCat::OAI->child_init();
+
     return 1;
 }
 
@@ -1,4 +1,4 @@
-# OpenILS::WWW::OAI manages OAI2 requests and responses.
+# OpenILS::Application::SuperCat::OAI manages OAI2 requests and responses.
 #
 # Copyright (c) 2014-2017 International Institute of Social History
 #
@@ -19,7 +19,7 @@
 # Author: Lucien van Wouw <lwo@iisg.nl>
 
 
-package OpenILS::Application::OAI;
+package OpenILS::Application::SuperCat::OAI;
 use strict; use warnings;
 
 use base qw/OpenILS::Application/;
@@ -54,7 +54,7 @@ sub child_init {
     $_xslt = new XML::LibXSLT;
 
     # Load the metadataformats that are configured.
-    my $metadata_format = OpenSRF::Utils::SettingsClient->new->config_value(apps => 'open-ils.oai')->{'app_settings'}->{'metadataformat'};
+    my $metadata_format = OpenSRF::Utils::SettingsClient->new->config_value(apps => 'open-ils.supercat')->{'app_settings'}->{'oai'}->{'metadataformat'};
     if ( $metadata_format ) {
         for my $schema ( keys %$metadata_format ) {
             $logger->info('Loading schema ' . $schema) ;
@@ -98,7 +98,7 @@ sub child_init {
     }
 
     # Load the mapping of 852 holdings.
-    my $copies = OpenSRF::Utils::SettingsClient->new->config_value(apps => 'open-ils.oai')->{'app_settings'}->{'copies'} ;
+    my $copies = OpenSRF::Utils::SettingsClient->new->config_value(apps => 'open-ils.supercat')->{'app_settings'}->{'oai'}->{'copies'} ;
     if ( $copies ) {
         foreach my $subfield_code (keys %$copies) {
             my $value = $copies->{$subfield_code};
@@ -117,8 +117,8 @@ sub child_init {
     }
 
     # Set the barcode filter and status filter
-    $barcode_filter = OpenSRF::Utils::SettingsClient->new->config_value(apps => 'open-ils.oai')->{'app_settings'}->{'barcode_filter'};
-    $status_filter = OpenSRF::Utils::SettingsClient->new->config_value(apps => 'open-ils.oai')->{'app_settings'}->{'status_filter'};
+    $barcode_filter = OpenSRF::Utils::SettingsClient->new->config_value(apps => 'open-ils.supercat')->{'app_settings'}->{'oai'}->{'barcode_filter'};
+    $status_filter = OpenSRF::Utils::SettingsClient->new->config_value(apps => 'open-ils.supercat')->{'app_settings'}->{'oai'}->{'status_filter'};
 
     return 1;
 }
@@ -142,7 +142,7 @@ sub list_record_formats {
 
 __PACKAGE__->register_method(
     method    => 'list_record_formats',
-    api_name  => 'open-ils.oai.record.formats',
+    api_name  => 'open-ils.supercat.oai.record.formats',
     api_level => 1,
     argc      => 0,
     signature =>
@@ -304,7 +304,7 @@ sub oai_biblio_retrieve {
 
 __PACKAGE__->register_method(
     method    => 'oai_biblio_retrieve',
-    api_name  => 'open-ils.oai.biblio.retrieve',
+    api_name  => 'open-ils.supercat.oai.biblio.retrieve',
     api_level => 1,
     argc      => 1,
     signature =>
@@ -401,7 +401,7 @@ sub oai_authority_retrieve {
 
 __PACKAGE__->register_method(
     method    => 'oai_authority_retrieve',
-    api_name  => 'open-ils.oai.authority.retrieve',
+    api_name  => 'open-ils.supercat.oai.authority.retrieve',
     api_level => 1,
     argc      => 1,
     signature =>
@@ -460,7 +460,7 @@ sub oai_list_retrieve {
 
 __PACKAGE__->register_method(
     method    => 'oai_list_retrieve',
-    api_name  => 'open-ils.oai.list.retrieve',
+    api_name  => 'open-ils.supercat.oai.list.retrieve',
     api_level => 1,
     argc      => 1,
     signature =>
index 0ca150c..13961b3 100644 (file)
@@ -71,11 +71,11 @@ sub child_init {
     my $idl = OpenSRF::Utils::SettingsClient->new->config_value('IDL');
     Fieldmapper->import(IDL => $idl);
 
-    $oai = OpenSRF::AppSession->create('open-ils.oai');
+    $oai = OpenSRF::AppSession->create('open-ils.supercat');
     $parser = new XML::LibXML;
     $xslt = new XML::LibXSLT;
 
-    my $app_settings = OpenSRF::Utils::SettingsClient->new->config_value(apps => 'open-ils.oai')->{'app_settings'};
+    my $app_settings = OpenSRF::Utils::SettingsClient->new->config_value(apps => 'open-ils.supercat')->{'app_settings'}->{'oai'};
     $base_url = $app_settings->{'base_url'} || 'localhost';
     $base_url =~/(.*)\/$/ ; # Keep all minus the trailing forward slash.
     $repository_identifier = $app_settings->{'repository_identifier'} || 'localhost';
@@ -284,7 +284,7 @@ sub getRecord {
         my $rec_id = $1 ;
 
         # Do we have a record ?
-        my $record = $oai->request('open-ils.oai.list.retrieve', $record_class, $rec_id, undef, undef, undef, 1, $deleted_record)->gather(1) ;
+        my $record = $oai->request('open-ils.supercat.oai.list.retrieve', $record_class, $rec_id, undef, undef, undef, 1, $deleted_record)->gather(1) ;
         if (@$record) {
             $response = HTTP::OAI::GetRecord->new();
             my $o = "Fieldmapper::oai::$record_class"->new(@$record[0]);
@@ -311,7 +311,7 @@ sub listIdentifiers {
     my ($record_class, $requestURL, $from, $until, $set, $metadataPrefix, $offset ) = @_;
     my $response;
 
-    my $r = $oai->request('open-ils.oai.list.retrieve', $record_class, $offset, $from, $until, $set, $max_count, $deleted_record)->gather(1) ;
+    my $r = $oai->request('open-ils.supercat.oai.list.retrieve', $record_class, $offset, $from, $until, $set, $max_count, $deleted_record)->gather(1) ;
     if (@$r) {
         my $cursor = 0 ;
         $response = HTTP::OAI::ListIdentifiers->new();
@@ -340,7 +340,7 @@ sub listRecords {
     my ($record_class, $requestURL, $from, $until, $set, $metadataPrefix, $offset ) = @_;
     my $response;
 
-    my $r = $oai->request('open-ils.oai.list.retrieve', $record_class, $offset, $from, $until, $set, $max_count, $deleted_record)->gather(1) ;
+    my $r = $oai->request('open-ils.supercat.oai.list.retrieve', $record_class, $offset, $from, $until, $set, $max_count, $deleted_record)->gather(1) ;
     if (@$r) {
         my $cursor = 0 ;
         $response = HTTP::OAI::ListRecords->new();
@@ -395,7 +395,7 @@ sub _record {
 
     if ( $o->deleted eq 'f' ) {
         my $md = new HTTP::OAI::Metadata() ;
-        my $xml = $oai->request('open-ils.oai.' . $record_class . '.retrieve', $o->rec_id, $metadataPrefix)->gather(1) ;
+        my $xml = $oai->request('open-ils.supercat.oai.' . $record_class . '.retrieve', $o->rec_id, $metadataPrefix)->gather(1) ;
         $md->dom( $parser->parse_string('<metadata>' . $xml . '</metadata>') ); # Not sure why I need to add the metadata element,
         $record->metadata( $md );                                               # because I expect ->metadata() would provide the wrapper for it.
     }
@@ -464,7 +464,7 @@ sub _load_oaisets_biblio {
 # oai_metadataformats = { metadataPrefix => { schema, metadataNamespace } }
 sub _load_oai_metadataformats {
 
-    my $list = $oai->request('open-ils.oai.record.formats')->gather(1);
+    my $list = $oai->request('open-ils.supercat.oai.record.formats')->gather(1);
     for my $record_browse_format ( @$list ) {
         my %h = %$record_browse_format ;
         my $metadataPrefix = (keys %h)[0] ;
index c03ddcb..942afa5 100644 (file)
@@ -1,7 +1,8 @@
-New OAI Service
-^^^^^^^^^^^^^^^
+OAI-PMH Data Provider Support
+^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
 
-This module is an optional service that exposes your catalog through the [OAI2 protocol](http://www.openarchives.org/OAI/openarchivesprotocol.html).
+Evergreen can now act as an OAI-PMH data provider, exposing the catalog to
+harvesting through the [OAI2 protocol](http://www.openarchives.org/OAI/openarchivesprotocol.html).
 
 
 Entry points
@@ -74,37 +75,12 @@ This mapping can be customized and extended with static subfields:
 Default configuration
 +++++++++++++++++++++
 
-See comments in opensrf.xml (in the open-ils.oai app_settings element)
-for default configuration and customization instructions. is commented
-in the open-ils.oai app_settings element.
+See comments in opensrf.xml (in the open-ils.supercat app_settings/oai element)
+for default configuration and customization instructions.
 
 Upgrade Instructions
 ++++++++++++++++++++
 
-**Activate the service**
-
-Refer to the service in the opensrf.xml activeapps element:
-```xml
-....
-<activeapps>
-    <appname>open-ils.oai</appname>
-```
-
-**Register the service with the router**
-
-Add the service to the public router in your opensrf_core.xml
-```xml
-<config>
-    <opensrf>
-        <routers>
-            <router>
-                <name>router</name>
-                <domain>public.realm</domain>
-                <services>
-                    <service>open-ils.oai</service>
-                    ...
-```
-
 Optional: Setting the datestamp
 +++++++++++++++++++++++++++++++