Catmandu-OAI-0.21000755000765000024 014662021556 13704 5ustar00hochstenstaff000000000000README100644000765000024 327414662021556 14653 0ustar00hochstenstaff000000000000Catmandu-OAI-0.21NAME Catmandu::OAI - Catmandu modules for working with OAI repositories SYNOPSIS # From the command line $ catmandu convert OAI --url http://biblio.ugent.be/oai --set allFtxt $ catmandu convert OAI --url http://biblio.ugent.be/oai --metadataPrefix mods --set books $ catmandu convert OAI --url http://biblio.ugent.be/oai --metadataPrefix mods --set books --handler raw $ catmandu import OAI --url http://biblio.ugent.be/oai --set allFtxt to MongoDB --database-name biblio # Harvest repository description $ catmandu convert OAI --url http://myrepo.org/oai --identify 1 # Harvest identifiers $ catmandu convert OAI --url http://myrepo.org/oai --listIdentifiers 1 # Harvest sets $ catmandu convert OAI --url http://myrepo.org/oai --listSets 1 # Harvest metadataFormats $ catmandu convert OAI --url http://myrepo.org/oai --listMetadataFormats 1 # Harvest one record $ catmandu convert OAI --url http://myrepo.org/oai --getRecord 1 --identifier oai:myrepo:1234 MODULES * Catmandu::Importer::OAI * Catmandu::Store::OAI AUTHOR Nicolas Steenlant, CONTRIBUTOR Patrick Hochstenbach, Jakob Voss, Nicolas Franck, LICENSE AND COPYRIGHT Copyright 2016 Ghent University Library This program is free software; you can redistribute it and/or modify it under the terms of either: the GNU General Public License as published by the Free Software Foundation; or the Artistic License. See http://dev.perl.org/licenses/ for more information. Changes100644000765000024 426014662021556 15262 0ustar00hochstenstaff000000000000Catmandu-OAI-0.21Revision history for Catmandu-OAI 0.21 2024-08-23 07:51:38 CEST - Maintenance release - Removing old dependencies checks 0.20 2023-10-04 14:56:53 CEST - Adding sleep option 0.19 2019-05-20 15:06:05 CEST - Adding a strict option for the importer 0.18 2017-10-17 13:50:01 CEST - Adding a Catmandu::Store implementation of OAI-PMH - Retry options should ignore OAI errors 0.17 2017-04-20 13:36:59 CEST - Removing the required realm when authenticating #23 0.16 2017-04-06 10:36:52 CEST - Adding support for Identify - Fixing POD errors 0.15 2017-04-05 15:50:08 CEST - Adding support for GetRecord and ListMetadataFormats - Updated POD 0.14 2017-03-27 10:28:10 CEST - Fixing memory leak issues 0.13 2017-03-21 13:32:20 CET - Making retries using exponential cutoff algorithm - Adding realm, username and password options 0.12 2016-12-15 15:19:57 CET - Adding max-retries feature to reconnect to a database when the network fails - More pod 0.11 2015-10-15 11:59:19 CEST - Adding support for proxys 0.10 2015-09-23 10:28:29 CEST - Adding support for MODS - Adding support for MARC collections 0.09 2015-08-17 14:50:39 CEST - Fixing repeated last page bug #10 0.08 2015-07-03 11:31:26 CEST - Don't bundle the dist.ini in distribution - Adding resumpionToken option 0.07 2015-05-20 16:15:02 CEST - Adding XSLT preprocessing 0.06 2014-06-22 11:10:24 CEST - Refactoring the handler code into Parsers, more in line with Catmandu::SRU - Adding marcxml parser 0.05 2014-06-22 09:34:00 CEST - Adding support for default XML::Struct parsing - Adding support for passing handlers by name and by invocation - Refactoring the RAW XML response into the Catmandu::Importer::OAI::RAW parser 0.04 2014-06-15 20:30:07 CEST - switched to the new HTTP::OAI with callbacks - adding a network test 0.03 2014-06-15 10:22:55 CEST - new option: dry (as supported my Catmandu::Importer::getJSON) - new option: listIdentifiers - changed packaging to Dist::Milla - adding more pod 0.02 2013-03-11 - pluggable record handlers - support set, metadataPrefix, from, until - more tolerant of bad xml 0.01 2012-05-04 - initial release LICENSE100644000765000024 4645714662021556 15032 0ustar00hochstenstaff000000000000Catmandu-OAI-0.21This software is copyright (c) 2024 by Patrick Hochstenbach. This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself. Terms of the Perl programming language system itself a) the GNU General Public License as published by the Free Software Foundation; either version 1, or (at your option) any later version, or b) the "Artistic License" --- The GNU General Public License, Version 1, February 1989 --- This software is Copyright (c) 2024 by Patrick Hochstenbach. This is free software, licensed under: The GNU General Public License, Version 1, February 1989 GNU GENERAL PUBLIC LICENSE Version 1, February 1989 Copyright (C) 1989 Free Software Foundation, Inc. 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA Everyone is permitted to copy and distribute verbatim copies of this license document, but changing it is not allowed. Preamble The license agreements of most software companies try to keep users at the mercy of those companies. By contrast, our General Public License is intended to guarantee your freedom to share and change free software--to make sure the software is free for all its users. The General Public License applies to the Free Software Foundation's software and to any other program whose authors commit to using it. You can use it for your programs, too. When we speak of free software, we are referring to freedom, not price. Specifically, the General Public License is designed to make sure that you have the freedom to give away or sell copies of free software, that you receive source code or can get it if you want it, that you can change the software or use pieces of it in new free programs; and that you know you can do these things. To protect your rights, we need to make restrictions that forbid anyone to deny you these rights or to ask you to surrender the rights. These restrictions translate to certain responsibilities for you if you distribute copies of the software, or if you modify it. For example, if you distribute copies of a such a program, whether gratis or for a fee, you must give the recipients all the rights that you have. You must make sure that they, too, receive or can get the source code. And you must tell them their rights. We protect your rights with two steps: (1) copyright the software, and (2) offer you this license which gives you legal permission to copy, distribute and/or modify the software. Also, for each author's protection and ours, we want to make certain that everyone understands that there is no warranty for this free software. If the software is modified by someone else and passed on, we want its recipients to know that what they have is not the original, so that any problems introduced by others will not reflect on the original authors' reputations. The precise terms and conditions for copying, distribution and modification follow. GNU GENERAL PUBLIC LICENSE TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION 0. This License Agreement applies to any program or other work which contains a notice placed by the copyright holder saying it may be distributed under the terms of this General Public License. The "Program", below, refers to any such program or work, and a "work based on the Program" means either the Program or any work containing the Program or a portion of it, either verbatim or with modifications. Each licensee is addressed as "you". 1. You may copy and distribute verbatim copies of the Program's source code as you receive it, in any medium, provided that you conspicuously and appropriately publish on each copy an appropriate copyright notice and disclaimer of warranty; keep intact all the notices that refer to this General Public License and to the absence of any warranty; and give any other recipients of the Program a copy of this General Public License along with the Program. You may charge a fee for the physical act of transferring a copy. 2. You may modify your copy or copies of the Program or any portion of it, and copy and distribute such modifications under the terms of Paragraph 1 above, provided that you also do the following: a) cause the modified files to carry prominent notices stating that you changed the files and the date of any change; and b) cause the whole of any work that you distribute or publish, that in whole or in part contains the Program or any part thereof, either with or without modifications, to be licensed at no charge to all third parties under the terms of this General Public License (except that you may choose to grant warranty protection to some or all third parties, at your option). c) If the modified program normally reads commands interactively when run, you must cause it, when started running for such interactive use in the simplest and most usual way, to print or display an announcement including an appropriate copyright notice and a notice that there is no warranty (or else, saying that you provide a warranty) and that users may redistribute the program under these conditions, and telling the user how to view a copy of this General Public License. d) You may charge a fee for the physical act of transferring a copy, and you may at your option offer warranty protection in exchange for a fee. Mere aggregation of another independent work with the Program (or its derivative) on a volume of a storage or distribution medium does not bring the other work under the scope of these terms. 3. You may copy and distribute the Program (or a portion or derivative of it, under Paragraph 2) in object code or executable form under the terms of Paragraphs 1 and 2 above provided that you also do one of the following: a) accompany it with the complete corresponding machine-readable source code, which must be distributed under the terms of Paragraphs 1 and 2 above; or, b) accompany it with a written offer, valid for at least three years, to give any third party free (except for a nominal charge for the cost of distribution) a complete machine-readable copy of the corresponding source code, to be distributed under the terms of Paragraphs 1 and 2 above; or, c) accompany it with the information you received as to where the corresponding source code may be obtained. (This alternative is allowed only for noncommercial distribution and only if you received the program in object code or executable form alone.) Source code for a work means the preferred form of the work for making modifications to it. For an executable file, complete source code means all the source code for all modules it contains; but, as a special exception, it need not include source code for modules which are standard libraries that accompany the operating system on which the executable file runs, or for standard header files or definitions files that accompany that operating system. 4. You may not copy, modify, sublicense, distribute or transfer the Program except as expressly provided under this General Public License. Any attempt otherwise to copy, modify, sublicense, distribute or transfer the Program is void, and will automatically terminate your rights to use the Program under this License. However, parties who have received copies, or rights to use copies, from you under this General Public License will not have their licenses terminated so long as such parties remain in full compliance. 5. By copying, distributing or modifying the Program (or any work based on the Program) you indicate your acceptance of this license to do so, and all its terms and conditions. 6. Each time you redistribute the Program (or any work based on the Program), the recipient automatically receives a license from the original licensor to copy, distribute or modify the Program subject to these terms and conditions. You may not impose any further restrictions on the recipients' exercise of the rights granted herein. 7. The Free Software Foundation may publish revised and/or new versions of the General Public License from time to time. Such new versions will be similar in spirit to the present version, but may differ in detail to address new problems or concerns. Each version is given a distinguishing version number. If the Program specifies a version number of the license which applies to it and "any later version", you have the option of following the terms and conditions either of that version or of any later version published by the Free Software Foundation. If the Program does not specify a version number of the license, you may choose any version ever published by the Free Software Foundation. 8. If you wish to incorporate parts of the Program into other free programs whose distribution conditions are different, write to the author to ask for permission. For software which is copyrighted by the Free Software Foundation, write to the Free Software Foundation; we sometimes make exceptions for this. Our decision will be guided by the two goals of preserving the free status of all derivatives of our free software and of promoting the sharing and reuse of software generally. NO WARRANTY 9. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION. 10. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. END OF TERMS AND CONDITIONS Appendix: How to Apply These Terms to Your New Programs If you develop a new program, and you want it to be of the greatest possible use to humanity, the best way to achieve this is to make it free software which everyone can redistribute and change under these terms. To do so, attach the following notices to the program. It is safest to attach them to the start of each source file to most effectively convey the exclusion of warranty; and each file should have at least the "copyright" line and a pointer to where the full notice is found. Copyright (C) 19yy This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 1, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301 USA Also add information on how to contact you by electronic and paper mail. If the program is interactive, make it output a short notice like this when it starts in an interactive mode: Gnomovision version 69, Copyright (C) 19xx name of author Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'. This is free software, and you are welcome to redistribute it under certain conditions; type `show c' for details. The hypothetical commands `show w' and `show c' should show the appropriate parts of the General Public License. Of course, the commands you use may be called something other than `show w' and `show c'; they could even be mouse-clicks or menu items--whatever suits your program. You should also get your employer (if you work as a programmer) or your school, if any, to sign a "copyright disclaimer" for the program, if necessary. Here a sample; alter the names: Yoyodyne, Inc., hereby disclaims all copyright interest in the program `Gnomovision' (a program to direct compilers to make passes at assemblers) written by James Hacker. , 1 April 1989 Ty Coon, President of Vice That's all there is to it! --- The Perl Artistic License 1.0 --- This software is Copyright (c) 2024 by Patrick Hochstenbach. This is free software, licensed under: The Perl Artistic License 1.0 The "Artistic License" Preamble The intent of this document is to state the conditions under which a Package may be copied, such that the Copyright Holder maintains some semblance of artistic control over the development of the package, while giving the users of the package the right to use and distribute the Package in a more-or-less customary fashion, plus the right to make reasonable modifications. Definitions: "Package" refers to the collection of files distributed by the Copyright Holder, and derivatives of that collection of files created through textual modification. "Standard Version" refers to such a Package if it has not been modified, or has been modified in accordance with the wishes of the Copyright Holder as specified below. "Copyright Holder" is whoever is named in the copyright or copyrights for the package. "You" is you, if you're thinking about copying or distributing this Package. "Reasonable copying fee" is whatever you can justify on the basis of media cost, duplication charges, time of people involved, and so on. (You will not be required to justify it to the Copyright Holder, but only to the computing community at large as a market that must bear the fee.) "Freely Available" means that no fee is charged for the item itself, though there may be fees involved in handling the item. It also means that recipients of the item may redistribute it under the same conditions they received it. 1. You may make and give away verbatim copies of the source form of the Standard Version of this Package without restriction, provided that you duplicate all of the original copyright notices and associated disclaimers. 2. You may apply bug fixes, portability fixes and other modifications derived from the Public Domain or from the Copyright Holder. A Package modified in such a way shall still be considered the Standard Version. 3. You may otherwise modify your copy of this Package in any way, provided that you insert a prominent notice in each changed file stating how and when you changed that file, and provided that you do at least ONE of the following: a) place your modifications in the Public Domain or otherwise make them Freely Available, such as by posting said modifications to Usenet or an equivalent medium, or placing the modifications on a major archive site such as uunet.uu.net, or by allowing the Copyright Holder to include your modifications in the Standard Version of the Package. b) use the modified Package only within your corporation or organization. c) rename any non-standard executables so the names do not conflict with standard executables, which must also be provided, and provide a separate manual page for each non-standard executable that clearly documents how it differs from the Standard Version. d) make other distribution arrangements with the Copyright Holder. 4. You may distribute the programs of this Package in object code or executable form, provided that you do at least ONE of the following: a) distribute a Standard Version of the executables and library files, together with instructions (in the manual page or equivalent) on where to get the Standard Version. b) accompany the distribution with the machine-readable source of the Package with your modifications. c) give non-standard executables non-standard names, and clearly document the differences in manual pages (or equivalent), together with instructions on where to get the Standard Version. d) make other distribution arrangements with the Copyright Holder. 5. You may charge a reasonable copying fee for any distribution of this Package. You may charge any fee you choose for support of this Package. You may not charge a fee for this Package itself. However, you may distribute this Package in aggregate with other (possibly commercial) programs as part of a larger (possibly commercial) software distribution provided that you do not advertise this Package as a product of your own. You may embed this Package's interpreter within an executable of yours (by linking); this shall be construed as a mere form of aggregation, provided that the complete Standard Version of the interpreter is so embedded. 6. The scripts and library files supplied as input to or produced as output from the programs of this Package do not automatically fall under the copyright of this Package, but belong to whoever generated them, and may be sold commercially, and may be aggregated with this Package. If such scripts or library files are aggregated with this Package via the so-called "undump" or "unexec" methods of producing a binary executable image, then distribution of such an image shall neither be construed as a distribution of this Package nor shall it fall under the restrictions of Paragraphs 3 and 4, provided that you do not represent such an executable image as a Standard Version of this Package. 7. C subroutines (or comparably compiled subroutines in other languages) supplied by you and linked into this Package in order to emulate subroutines and variables of the language defined by this Package shall not be considered part of this Package, but are the equivalent of input as in Paragraph 6, provided these subroutines do not change the language in any way that would cause it to fail the regression tests for the language. 8. Aggregation of this Package with a commercial distribution is always permitted provided that the use of this Package is embedded; that is, when no overt attempt is made to make this Package's interfaces visible to the end user of the commercial distribution. Such use shall not be construed as a distribution of this Package. 9. The name of the Copyright Holder may not be used to endorse or promote products derived from this software without specific prior written permission. 10. THIS PACKAGE IS PROVIDED "AS IS" AND WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. The End cpanfile100644000765000024 104614662021556 15472 0ustar00hochstenstaff000000000000Catmandu-OAI-0.21requires 'perl', 'v5.10.1'; on 'test', sub { requires 'Test::Simple', '1.001003'; requires 'Test::More', '1.001003'; requires 'Test::Exception','0.32'; requires 'Test::Pod'; }; requires 'Catmandu', '>=1.0306'; requires 'Catmandu::XML', '>=0.16'; requires 'XML::LibXML', 0; requires 'HTTP::OAI', '>=4.03'; requires 'Moo', '>=1.0'; requires 'XML::Struct', '>=0.18'; requires 'MODS::Record', '>=0.11'; requires 'IO::String', '0'; requires 'URI','0'; # Need recent SSL to talk to https endpoint correctly requires 'IO::Socket::SSL', '>=1.993';Build.PL100644000765000024 26314662021556 15242 0ustar00hochstenstaff000000000000Catmandu-OAI-0.21# This Build.PL for Catmandu-OAI was generated by Dist::Zilla::Plugin::ModuleBuildTiny 0.017. use strict; use warnings; use v5.10.1; use Module::Build::Tiny 0.034; Build_PL(); META.yml100644000765000024 314614662021556 15242 0ustar00hochstenstaff000000000000Catmandu-OAI-0.21--- abstract: 'Catmandu modules for working with OAI repositories' author: - 'Nicolas Steenlant, C<< >>' build_requires: Test::Exception: '0.32' Test::More: '1.001003' Test::Pod: '0' Test::Simple: '1.001003' configure_requires: Module::Build::Tiny: '0.034' dynamic_config: 0 generated_by: 'Dist::Milla version v1.0.22, Dist::Zilla version 6.032, CPAN::Meta::Converter version 2.150001' license: perl meta-spec: url: http://module-build.sourceforge.net/META-spec-v1.4.html version: '1.4' name: Catmandu-OAI no_index: directory: - eg - examples - inc - share - t - xt requires: Catmandu: '1.0306' Catmandu::XML: '0.16' HTTP::OAI: '4.03' IO::Socket::SSL: '1.993' IO::String: '0' MODS::Record: '0.11' Moo: '1.0' URI: '0' XML::LibXML: '0' XML::Struct: '0.18' perl: v5.10.1 resources: bugtracker: https://github.com/LibreCat/Catmandu-OAI/issues homepage: https://github.com/LibreCat/Catmandu-OAI repository: https://github.com/LibreCat/Catmandu-OAI.git version: '0.21' x_contributors: - 'Christian Pietsch ' - 'Jakob Voss ' - 'Matthias Vandermaesen ' - 'Nicolas Franck ' - 'Nicolas Franck ' - 'Nicolas Steenlant ' - 'Patrick Hochstenbach ' - 'Yanick Champoux ' x_generated_by_perl: v5.22.1 x_serialization_backend: 'YAML::Tiny version 1.74' x_spdx_expression: 'Artistic-1.0-Perl OR GPL-1.0-or-later' x_static_install: 1 MANIFEST100644000765000024 113614662021556 15117 0ustar00hochstenstaff000000000000Catmandu-OAI-0.21# This file was automatically generated by Dist::Zilla::Plugin::Manifest v6.032. Build.PL Changes LICENSE MANIFEST MANIFEST.SKIP META.json META.yml README cpanfile lib/Catmandu/Importer/OAI.pm lib/Catmandu/Importer/OAI/Parser/marcxml.pm lib/Catmandu/Importer/OAI/Parser/mods.pm lib/Catmandu/Importer/OAI/Parser/oai_dc.pm lib/Catmandu/Importer/OAI/Parser/raw.pm lib/Catmandu/Importer/OAI/Parser/struct.pm lib/Catmandu/OAI.pm lib/Catmandu/Store/OAI.pm lib/Catmandu/Store/OAI/Bag.pm t/00-load.t t/01-importer.t t/02-handler.t t/20-xslt.t t/author-pod-syntax.t t/epicur.xml t/lib/TestParser.pm t/transform.xsl META.json100644000765000024 506614662021556 15415 0ustar00hochstenstaff000000000000Catmandu-OAI-0.21{ "abstract" : "Catmandu modules for working with OAI repositories", "author" : [ "Nicolas Steenlant, C<< >>" ], "dynamic_config" : 0, "generated_by" : "Dist::Milla version v1.0.22, Dist::Zilla version 6.032, CPAN::Meta::Converter version 2.150001", "license" : [ "perl_5" ], "meta-spec" : { "url" : "http://search.cpan.org/perldoc?CPAN::Meta::Spec", "version" : 2 }, "name" : "Catmandu-OAI", "no_index" : { "directory" : [ "eg", "examples", "inc", "share", "t", "xt" ] }, "prereqs" : { "configure" : { "requires" : { "Module::Build::Tiny" : "0.034" } }, "develop" : { "requires" : { "Dist::Milla" : "v1.0.22", "Test::Pod" : "1.41" } }, "runtime" : { "requires" : { "Catmandu" : "1.0306", "Catmandu::XML" : "0.16", "HTTP::OAI" : "4.03", "IO::Socket::SSL" : "1.993", "IO::String" : "0", "MODS::Record" : "0.11", "Moo" : "1.0", "URI" : "0", "XML::LibXML" : "0", "XML::Struct" : "0.18", "perl" : "v5.10.1" } }, "test" : { "requires" : { "Test::Exception" : "0.32", "Test::More" : "1.001003", "Test::Pod" : "0", "Test::Simple" : "1.001003" } } }, "release_status" : "stable", "resources" : { "bugtracker" : { "web" : "https://github.com/LibreCat/Catmandu-OAI/issues" }, "homepage" : "https://github.com/LibreCat/Catmandu-OAI", "repository" : { "type" : "git", "url" : "https://github.com/LibreCat/Catmandu-OAI.git", "web" : "https://github.com/LibreCat/Catmandu-OAI" } }, "version" : "0.21", "x_contributors" : [ "Christian Pietsch ", "Jakob Voss ", "Matthias Vandermaesen ", "Nicolas Franck ", "Nicolas Franck ", "Nicolas Steenlant ", "Patrick Hochstenbach ", "Yanick Champoux " ], "x_generated_by_perl" : "v5.22.1", "x_serialization_backend" : "Cpanel::JSON::XS version 4.38", "x_spdx_expression" : "Artistic-1.0-Perl OR GPL-1.0-or-later", "x_static_install" : 1 } t000755000765000024 014662021556 14070 5ustar00hochstenstaff000000000000Catmandu-OAI-0.2100-load.t100644000765000024 23614662021556 15532 0ustar00hochstenstaff000000000000Catmandu-OAI-0.21/t#!perl -T use strict; use warnings; use Test::More; BEGIN { use_ok 'Catmandu::Importer::OAI'; } require_ok 'Catmandu::Importer::OAI'; done_testing 2; 20-xslt.t100644000765000024 150014662021556 15622 0ustar00hochstenstaff000000000000Catmandu-OAI-0.21/tuse strict; use warnings; use version; use Catmandu::Importer::OAI; use Test::More; my $dom = XML::LibXML->load_xml( location => 't/epicur.xml' ); sub oai_xslt { Catmandu::Importer::OAI->new( url => 'http://example.org/', xslt => 't/transform.xsl', @_ )->handle_record($dom) } is_deeply oai_xslt( handler => 'raw' ), { _metadata => "\nurn:nbn:de:bsz:16-ip-164907\n" }; is_deeply oai_xslt( handler => 'struct' ), { '_metadata' => [ 'urn_new', { url => 'https://journals.ub.uni-heidelberg.de/index.php/ip/article/view/16490/12358' }, [ 'urn:nbn:de:bsz:16-ip-164907' ] ] }; is_deeply oai_xslt(), { urn_new => [ 'urn:nbn:de:bsz:16-ip-164907' ] }; done_testing; epicur.xml100644000765000024 166614662021556 16252 0ustar00hochstenstaff000000000000Catmandu-OAI-0.21/t urn:nbn:de:bsz:16-ip-164907 https://journals.ub.uni-heidelberg.de/index.php/ip/article/view/16490/12358 text/html https://journals.ub.uni-heidelberg.de/index.php/ip/article/download/16490/12358 application/pdf MANIFEST.SKIP100644000765000024 1114662021556 15613 0ustar00hochstenstaff000000000000Catmandu-OAI-0.21dist.ini 02-handler.t100644000765000024 214214662021556 16250 0ustar00hochstenstaff000000000000Catmandu-OAI-0.21/t#!/usr/bin/perl use lib qw(t/lib); use strict; use warnings; use Catmandu::Importer::OAI; use Test::More; use TestParser; use Data::Dumper; my $handler = TestParser->new; ok $handler; if ($ENV{RELEASE_TESTING}) { my $importer = Catmandu::Importer::OAI->new( url => 'http://lib.ugent.be/oai', metadataPrefix => 'marcxml', set => "eu", handler => $handler, ); my $record = $importer->first; ok $record , 'listrecords'; is $record->{test}, 'ok' , 'got correct data'; #--- $importer = Catmandu::Importer::OAI->new( url => 'http://lib.ugent.be/oai', metadataPrefix => 'marcxml', set => "eu", handler => '+TestParser', ); $record = $importer->first; ok $record , 'listrecords'; is $record->{test}, 'ok' , 'got correct data'; #--- $importer = Catmandu::Importer::OAI->new( url => 'http://lib.ugent.be/oai', metadataPrefix => 'marcxml', set => "eu", handler => sub { return { test => 123 }; }, ); $record = $importer->first; ok $record , 'listrecords'; is $record->{test}, '123' , 'got correct data'; } done_testing;01-importer.t100644000765000024 141614662021556 16476 0ustar00hochstenstaff000000000000Catmandu-OAI-0.21/tuse strict; use warnings; use Catmandu::Importer::OAI; use Test::More; my $importer = Catmandu::Importer::OAI->new( url => 'http://biblio.ugent.be/oai', set => "allFtxt", dry => 1, ); my $record = $importer->first; ok exists $record->{url} , 'dry run'; # skip live testing by default (mock server instead) if ($ENV{RELEASE_TESTING}) { $importer = Catmandu::Importer::OAI->new( url => 'http://biblio.ugent.be/oai', set => "allFtxt" ); $record = $importer->first; ok $record , 'listrecords'; $importer = Catmandu::Importer::OAI->new( url => 'http://biblio.ugent.be/oai', set => "allFtxt", listIdentifiers => 1, ); $record = $importer->first; ok $record, 'listidentifiers'; } done_testing; transform.xsl100644000765000024 112514662021556 16772 0ustar00hochstenstaff000000000000Catmandu-OAI-0.21/t Catmandu000755000765000024 014662021556 16127 5ustar00hochstenstaff000000000000Catmandu-OAI-0.21/libOAI.pm100644000765000024 333514662021556 17241 0ustar00hochstenstaff000000000000Catmandu-OAI-0.21/lib/Catmandupackage Catmandu::OAI; =head1 NAME Catmandu::OAI - Catmandu modules for working with OAI repositories =head1 SYNOPSIS # From the command line $ catmandu convert OAI --url http://biblio.ugent.be/oai --set allFtxt $ catmandu convert OAI --url http://biblio.ugent.be/oai --metadataPrefix mods --set books $ catmandu convert OAI --url http://biblio.ugent.be/oai --metadataPrefix mods --set books --handler raw $ catmandu import OAI --url http://biblio.ugent.be/oai --set allFtxt to MongoDB --database-name biblio # Harvest repository description $ catmandu convert OAI --url http://myrepo.org/oai --identify 1 # Harvest identifiers $ catmandu convert OAI --url http://myrepo.org/oai --listIdentifiers 1 # Harvest sets $ catmandu convert OAI --url http://myrepo.org/oai --listSets 1 # Harvest metadataFormats $ catmandu convert OAI --url http://myrepo.org/oai --listMetadataFormats 1 # Harvest one record $ catmandu convert OAI --url http://myrepo.org/oai --getRecord 1 --identifier oai:myrepo:1234 =cut our $VERSION = '0.21'; =head1 MODULES =over =item * L =item * L =back =head1 AUTHOR Nicolas Steenlant, C<< >> =head1 CONTRIBUTOR Patrick Hochstenbach, C<< >> Jakob Voss, C<< >> Nicolas Franck, C<< >> =head1 LICENSE AND COPYRIGHT Copyright 2016 Ghent University Library This program is free software; you can redistribute it and/or modify it under the terms of either: the GNU General Public License as published by the Free Software Foundation; or the Artistic License. See http://dev.perl.org/licenses/ for more information. =cut 1; lib000755000765000024 014662021556 14636 5ustar00hochstenstaff000000000000Catmandu-OAI-0.21/tTestParser.pm100644000765000024 36514662021556 17414 0ustar00hochstenstaff000000000000Catmandu-OAI-0.21/t/libpackage TestParser; use Catmandu::Sane; use Moo; has metadataPrefix => (is => 'ro' , default => sub { "marcxml" }); sub parse { my ($self,$dom) = @_; return undef unless defined $dom; my $rec = { test => 'ok' }; $rec; } 1;author-pod-syntax.t100644000765000024 45414662021556 20006 0ustar00hochstenstaff000000000000Catmandu-OAI-0.21/t#!perl BEGIN { unless ($ENV{AUTHOR_TESTING}) { print qq{1..0 # SKIP these tests are for testing by the author\n}; exit } } # This file was automatically generated by Dist::Zilla::Plugin::PodSyntaxTests. use strict; use warnings; use Test::More; use Test::Pod 1.41; all_pod_files_ok(); Store000755000765000024 014662021556 17223 5ustar00hochstenstaff000000000000Catmandu-OAI-0.21/lib/CatmanduOAI.pm100644000765000024 417014662021556 20333 0ustar00hochstenstaff000000000000Catmandu-OAI-0.21/lib/Catmandu/Storepackage Catmandu::Store::OAI; use Catmandu::Sane; our $VERSION = '0.21'; use Moo; use Catmandu::Util qw(:is); use Catmandu::Importer::OAI; use Catmandu::Store::OAI::Bag; use namespace::clean; with 'Catmandu::Store'; has url => (is => 'ro', required => 1); has metadataPrefix => (is => 'ro', default => sub { "oai_dc" }); has handler => (is => 'ro', default => sub { "oai_dc" }); has oai => (is => 'lazy'); sub _build_oai { my ($self) = @_; Catmandu::Importer::OAI->new( url => $self->url , metadataPrefix => $self->metadataPrefix , handler => $self->handler , ); } 1; __END__ =pod =head1 NAME Catmandu::Store::OAI - A Catmandu store backed by OAI-PMH =head1 SYNOPSIS # From the command line # Export data from OAI $ catmandu export OAI --url http://somewhere.org/oai to JSON > data.json # Export only one record $ catmandu export OAI --url http://somewhere.org/oai --id 1234 # Export from a set $ catmandu export OAI --url http://somewhere.org/oai --bag fulltext # From Perl use Catmandu; my $store = Catmandu->store('OAI', url => ' http://somewhere.org/oai '); # All bags are iterators $store->bag->each(sub { ... }); $store->bag->take(10)->each(sub { ... }); my $rec = $store->bag->get('1234'); =head1 METHODS =head2 new(url => $url , metadataPrefix => $metadataPrefix , handler => $handler) Create a new Catmandu::Store::OAI store connected to baseURL $url. =head1 INHERITED METHODS This Catmandu::Store implements: =over 3 =item L =back Each Catmandu::Bag in this Catmandu::Store implements: =over 3 =item L =back =head1 SEE ALSO L , L =head1 AUTHOR Patrick Hochstenbach, C<< patrick.hochstenbach at ugent.be >> =head1 LICENSE AND COPYRIGHT This program is free software; you can redistribute it and/or modify it under the terms of either: the GNU General Public License as published by the Free Software Foundation; or the Artistic License. See http://dev.perl.org/licenses/ for more information. =cut Importer000755000765000024 014662021556 17730 5ustar00hochstenstaff000000000000Catmandu-OAI-0.21/lib/CatmanduOAI.pm100644000765000024 4716614662021556 21074 0ustar00hochstenstaff000000000000Catmandu-OAI-0.21/lib/Catmandu/Importerpackage Catmandu::Importer::OAI; use Catmandu::Sane; use Catmandu::Util qw(:is); use Moo; use Scalar::Util qw(blessed); use HTTP::OAI; use Carp; use Catmandu::Error; use URI; our $VERSION = '0.21'; with 'Catmandu::Importer'; has url => (is => 'ro', required => 1); has identifier => (is => 'ro'); has metadataPrefix => (is => 'ro', default => sub { "oai_dc" }); has set => (is => 'ro'); has from => (is => 'ro'); has until => (is => 'ro'); has resumptionToken => (is => 'ro'); has strict => (is => 'ro'); has identify => (is => 'ro'); has listIdentifiers => (is => 'ro'); has listRecords => (is => 'ro'); has listSets => (is => 'ro'); has listMetadataFormats => (is => 'ro'); has getRecord => (is => 'ro'); has oai => (is => 'ro', lazy => 1, builder => 1); has dry => (is => 'ro'); has handler => (is => 'rw', lazy => 1 , builder => 1, coerce => \&_coerce_handler ); has xslt => (is => 'ro', coerce => \&_coerce_xslt ); has sleep => ( is => 'ro', default => sub { 0 } ); has max_retries => ( is => 'ro', default => sub { 0 } ); has _retried => ( is => 'rw', default => sub { 0; } ); has _xml_handlers => ( is => 'ro', default => sub { +{} } ); has realm => ( is => 'ro', predicate => 1 ); has username => ( is => 'ro', predicate => 1 ); has password => ( is => 'ro', predicate => 1 ); sub _build_handler { my ($self) = @_; if ($self->metadataPrefix eq 'oai_dc') { return 'oai_dc'; } elsif ($self->metadataPrefix eq 'marcxml') { return 'marcxml'; } elsif ($self->metadataPrefix eq 'mods') { return 'mods'; } else { return 'struct'; } } sub _coerce_handler { my ($handler) = @_; return $handler if is_invocant($handler) or is_code_ref($handler); if (is_string($handler) && !is_number($handler)) { my $class = $handler =~ /^\+(.+)/ ? $1 : "Catmandu::Importer::OAI::Parser::$handler"; my $handler; eval { $handler = Catmandu::Util::require_package($class)->new; }; if ($@) { croak $@; } else { return $handler; } } return sub { return { _metadata => readXML($_[0]) } }; } sub _coerce_xslt { eval { Catmandu::Util::require_package('Catmandu::XML::Transformer') ->new( stylesheet => $_[0] ) } or croak $@; } sub _build_oai { my ($self) = @_; my $agent = HTTP::OAI::Harvester->new(baseURL => $self->url, resume => 0, keep_alive => 1); if( $self->has_username && $self->has_password ) { my $uri = URI->new( $self->url ); my @credentials = ( $uri->host_port, $self->realm || undef, $self->username, $self->password ); $agent->credentials( @credentials ); } $agent->env_proxy; $agent; } sub _xml_handler_for_node { my ( $self, $node ) = @_; my $ns = $node->namespaceURI(); my $type; if( $ns eq "http://www.openarchives.org/OAI/2.0/oai_dc/" ){ $type = "oai_dc"; } elsif( $ns eq "http://www.loc.gov/MARC21/slim" ){ $type = "marcxml"; } elsif( $ns eq "http://www.loc.gov/mods/v3" ){ $type = "mods"; } else{ $type = "struct"; } $self->_xml_handlers()->{$type} ||= Catmandu::Util::require_package( "Catmandu::Importer::OAI::Parser::$type" )->new(); } sub _map_set { my ($self, $rec) = @_; +{ _id => $rec->setSpec(), setSpec => $rec->setSpec(), setName => $rec->setName(), setDescription => [ map { #root: 'setDescription' my @root = $_->dom()->childNodes(); #child: oai_dc, marcxml, mods.. my @children = $root[0]->childNodes(); $self->_xml_handler_for_node( $children[0] )->parse( $children[0] ); } $rec->setDescription() ] }; } sub _map_format { my ($self, $rec) = @_; +{ _id => $rec->metadataPrefix, metadataPrefix => $rec->metadataPrefix(), metadataNamespace => $rec->metadataNamespace(), schema => $rec->schema() }; } sub _map_identify { my ($self, $rec) = @_; my @description; if ($rec->description) { for my $desc ($rec->description) { push @description , $desc->dom->toString; } } +{ _id => $rec->baseURL, baseURL => $rec->baseURL, granularity => $rec->granularity, deletedRecord => $rec->deletedRecord, earliestDatestamp => $rec->earliestDatestamp, adminEmail => $rec->adminEmail, protocolVersion => $rec->protocolVersion, repositoryName => $rec->repositoryName, description => \@description }; } sub _map_record { my ($self, $rec) = @_; my $sets = [ $rec->header->setSpec ]; my $identifier = $rec->identifier; my $datestamp = $rec->datestamp; my $status = $rec->status // ""; my $dom = $rec->metadata ? $rec->metadata->dom->nonBlankChildNodes->[0]->nonBlankChildNodes->[0] : undef; my $about = []; for ($rec->about) { push(@$about , $_->dom->nonBlankChildNodes->[0]->nonBlankChildNodes->[0]->toString); } my $values = $self->handle_record($dom) // { }; my $data = { _id => $identifier , _identifier => $identifier , _datestamp => $datestamp , _status => $status , _setSpec => $sets , _about => $about , %$values }; $data; } sub _args { my $self = $_[0]; my %args = ( identifier => $self->identifier, metadataPrefix => $self->metadataPrefix, set => $self->set , from => $self->from , until => $self->until , force => !$self->strict , ); for( keys %args ) { delete $args{$_} if !defined($args{$_}) || !length($args{$_}); } return %args; } sub _verb { my $self = $_[0]; if ($self->identify) { return 'Identify'; } elsif ($self->listIdentifiers) { return 'ListIdentifiers'; } elsif ($self->listSets) { return 'ListSets'; } elsif ($self->getRecord) { return 'GetRecord'; } elsif ($self->listMetadataFormats) { return 'ListMetadataFormats'; } elsif ($self->listRecords) { return 'ListRecords'; } else { return 'ListRecords'; } } sub handle_record { my ($self, $dom) = @_; return unless $dom; $dom = $self->xslt->transform($dom) if $self->xslt; return blessed($self->handler) ? $self->handler->parse($dom) : $self->handler->($dom); } sub dry_run { my ($self) = @_; sub { state $called = 0; return if $called; $called = 1; # TODO: make sure that HTTP::OAI does not change this internal method return +{ url => $self->oai->_buildurl( $self->_args(), verb => $self->_verb() ) }; }; } sub _retry { my ( $self, $sub ) = @_; $self->_retried( 0 ); my $res; while ( 1 ) { $res = $sub->(); if ($res->is_error && ref($res) ne 'HTTP::OAI::Response') { my $max_retries = $self->max_retries(); my $_retried = $self->_retried(); if ( $max_retries > 0 && $_retried < $max_retries ){ $_retried++; #exponential backoff: [0 .. 2^c [ my $n_seconds = int( 2**$_retried ); $self->log->error("failed, retrying after $n_seconds"); sleep $n_seconds; $self->_retried( $_retried ); next; } else { my $err_msg = $self->url . " : " . $res->message." (stopped after ".$self->_retried()." retries)"; $self->log->error( $err_msg ); Catmandu::Error->throw( $err_msg ); } } last; } $res; } sub _list_records { my $self = $_[0]; my $args = $_[1]; sub { state $stack = []; state $resumptionToken = $self->resumptionToken; state $resumptionData = {}; state $done = 0; my $fill_stack = sub { push @$stack , shift; }; if (@$stack <= 1 && $done == 0) { my %args = $args ? %$args : $self->_args; # Use the resumptionToken if one found on the last run, or if it was # undefined (last record) if (defined $resumptionToken) { my $verb = $args{verb}; %args = (verb => $verb , resumptionToken => $resumptionToken); } my $sub = $self->listIdentifiers() ? sub { $self->oai->ListIdentifiers( %args , onRecord => $fill_stack ); } : sub { $self->oai->ListRecords( %args , onRecord => $fill_stack ); }; my $res = $self->_retry( $sub ); if (defined $res->resumptionToken) { $resumptionToken = $res->resumptionToken->resumptionToken; $resumptionData->{token} = $resumptionToken; $resumptionData->{expirationDate} = $res->resumptionToken->expirationDate; $resumptionData->{completeListSize} = $res->resumptionToken->completeListSize; $resumptionData->{cursor} = $res->resumptionToken->cursor; } else { $resumptionToken = undef; } unless (defined $resumptionToken && length $resumptionToken) { $done = 1; } if ($self->sleep) { sleep $self->sleep; } } if (my $rec = shift @$stack) { if ($rec->isa('HTTP::OAI::Record')) { my $rec = $self->_map_record($rec); $rec->{_resumptionToken} = $resumptionToken if defined($resumptionToken); $rec->{_resumption} = $resumptionData if defined($resumptionData); return $rec; } else { my $rec = { _id => $rec->identifier, _datestamp => $rec->datestamp, _status => $rec->status // "", }; $rec->{_resumptionToken} = $resumptionToken if defined($resumptionToken); $rec->{_resumption} = $resumptionData if defined($resumptionData); return $rec; } } return undef; }; } sub _list_sets { my $self = $_[0]; sub { state $stack = []; state $done = 0; my $fill_stack = sub { push @$stack , shift; }; if (@$stack <= 1 && $done == 0) { my $sub = sub { $self->oai->ListSets( onRecord => $fill_stack ); }; my $res = $self->_retry( $sub ); $done = 1; } if (my $rec = shift @$stack) { return $self->_map_set($rec); } return undef; }; } sub _get_record { my $self = $_[0]; my $args = $_[1]; sub { state $stack = []; state $done = 0; my $fill_stack = sub { push @$stack , shift; }; if (@$stack <= 1 && $done == 0) { my %args = $args ? %$args : $self->_args; my $sub = sub { $self->oai->GetRecord(%args , onRecord => $fill_stack) }; my $res = $self->_retry( $sub ); $done = 1; } if (my $rec = shift @$stack) { if ($rec->isa('HTTP::OAI::Record')) { return $self->_map_record($rec); } else { return { _id => $rec->identifier, _datestamp => $rec->datestamp, _status => $rec->status // "", } } } return undef; }; } sub _list_metadata_formats { my $self = $_[0]; my $args = $_[1]; sub { state $stack = []; state $done = 0; my $fill_stack = sub { push @$stack , shift; }; if (@$stack <= 1 && $done == 0) { my %args = $args ? %$args : $self->_args; delete $args{metadataPrefix}; my $sub = sub { $self->oai->ListMetadataFormats( %args ); }; my $res = $self->_retry( $sub ); while( my $mdf = $res->next ) { $fill_stack->($mdf); } $done = 1; } if (my $rec = shift @$stack) { return $self->_map_format($rec); } return undef; }; } sub _identify { my $self = $_[0]; sub { state $stack = []; state $done = 0; my $fill_stack = sub { push @$stack , shift; }; if (@$stack <= 1 && $done == 0) { my $sub = sub { $self->oai->Identify( onRecord => $fill_stack) }; my $res = $self->_retry( $sub ); $fill_stack->($res); $done = 1; } if (my $rec = shift @$stack) { return $self->_map_identify($rec); } return undef; }; } sub oai_run { my ($self) = @_; if ($self->identify) { return $self->_identify; } elsif ($self->listIdentifiers) { return $self->_list_records; } elsif ($self->listSets) { return $self->_list_sets } elsif ($self->getRecord) { return $self->_get_record; } elsif ($self->listMetadataFormats) { return $self->_list_metadata_formats; } elsif ($self->listRecords) { return $self->_list_records } else { return $self->_list_records } } sub generator { my ($self) = @_; return $self->dry ? $self->dry_run : $self->oai_run; } 1; __END__ =head1 NAME Catmandu::Importer::OAI - Package that imports OAI-PMH feeds =head1 SYNOPSIS # From the command line # Harvest records $ catmandu convert OAI --url http://myrepo.org/oai $ catmandu convert OAI --url http://myrepo.org/oai --metadataPrefix didl --handler raw # Harvest repository description $ catmandu convert OAI --url http://myrepo.org/oai --identify 1 # Harvest identifiers $ catmandu convert OAI --url http://myrepo.org/oai --listIdentifiers 1 # Harvest sets $ catmandu convert OAI --url http://myrepo.org/oai --listSets 1 # Harvest metadataFormats $ catmandu convert OAI --url http://myrepo.org/oai --listMetadataFormats 1 # Harvest one record $ catmandu convert OAI --url http://myrepo.org/oai --getRecord 1 --identifier oai:myrepo:1234 =head1 DESCRIPTION L is an L importer to harvest metadata records from an OAI-PMH endpoint. =head1 CONFIGURATION =over =item url OAI-PMH Base URL. =item metadataPrefix Metadata prefix to specify the metadata format. Set to C by default. =item handler( sub {} | $object | 'NAME' | '+NAME' ) Handler to transform each record from XML DOM (L) into Perl hash. Handlers can be provided as function reference, an instance of a Perl package that implements 'parse', or by a package NAME. Package names should be prepended by C<+> or prefixed with C. E.g C will create a C instance. By default the handler L is used for metadataPrefix C, L for C, L for C, and L for other formats. In addition there is L to return the XML as it is. =item identifier Option return only results for this particular identifier =item set An optional set for selective harvesting. =item from An optional datetime value (YYYY-MM-DD or YYYY-MM-DDThh:mm:ssZ) as lower bound for datestamp-based selective harvesting. =item until An optional datetime value (YYYY-MM-DD or YYYY-MM-DDThh:mm:ssZ) as upper bound for datestamp-based selective harvesting. =item identify Harvest the repository description instead of all records. =item getRecord Harvest one record instead of all records. =item listIdentifiers Harvest identifiers instead of full records. =item listRecords Harvest full records. Default operation. =item listSets Harvest sets instead of records. =item listMetadataFormats Harvest metadata formats of records =item resumptionToken An optional resumptionToken to start harvesting from. =item dry Don't do any HTTP requests but return URLs that data would be queried from. =item strict Optional validate all parameters first against the OAI 2 spefications before sending it to an OAI server. Default: undef. =item xslt Preprocess XML records with XSLT script(s) given as comma separated list or array reference. Requires L. =item max_retries When an oai request fails, the importer will retry this number of times. Set to '0' by default. Internally the exponential backoff algorithm is used for this. This means that after every failed request the importer will choose a random number between 0 and 2^collision (excluded), and wait that number of seconds. So the actual ammount of time before the importer stops can differ: first retry: wait [ 0..2^1 [ seconds second retry: wait [ 0..2^2 [ seconds third retry: wait [ 0..2^3 [ seconds .. =item sleep Sleep a number of seconds between OAI-PMH calls to the endpoint (default 0). =item realm An optional realm value. This value is used when the importer harvests from a repository which is secured with basic authentication through Integrated Windows Authentication (NTLM or Kerberos). =item username An optional username value. This value is used when the importer harvests from a repository which is secured with basic authentication. =item password An optional password value. This value is used when the importer harvests from a repository which is secured with basic authentication. =back =head1 METHOD Every Catmandu::Importer is a L all its methods are inherited. The Catmandu::Importer::OAI methods are not idempotent: OAI-PMH feeds can only be read once. In addition to methods inherited from L, this module provides the following public methods: =head2 handle_record( $dom ) Process an XML DOM as with xslt and handler as configured and return the result. =head1 ENVIRONMENT If you are connected to the internet via a proxy server you need to set the coordinates to this proxy in your environment: export http_proxy="http://localhost:8080" If you are connecting to a HTTPS server and don't want to verify the validity of certificates of the peer you can set the PERL_LWP_SSL_VERIFY_HOSTNAME to false in your environment. This maybe required to connect to broken SSL servers: export PERL_LWP_SSL_VERIFY_HOSTNAME=0 =head1 SEE ALSO L , L =head1 AUTHOR Nicolas Steenlant, C<< >> =head1 CONTRIBUTOR Patrick Hochstenbach, C<< >> Jakob Voss, C<< >> Nicolas Franck, C<< >> =head1 LICENSE AND COPYRIGHT Copyright 2016 Ghent University Library This program is free software; you can redistribute it and/or modify it under the terms of either: the GNU General Public License as published by the Free Software Foundation; or the Artistic License. See http://dev.perl.org/licenses/ for more information. =cut OAI000755000765000024 014662021556 17633 5ustar00hochstenstaff000000000000Catmandu-OAI-0.21/lib/Catmandu/StoreBag.pm100644000765000024 401714662021556 21024 0ustar00hochstenstaff000000000000Catmandu-OAI-0.21/lib/Catmandu/Store/OAIpackage Catmandu::Store::OAI::Bag; use Catmandu::Sane; use Catmandu::Util qw(:is); use Carp qw(confess); use Catmandu::Hits; use Catmandu::Error; use Moo; our $VERSION = '0.21'; with 'Catmandu::Bag'; sub generator { my ($self) = @_; my $oai = $self->store->oai; my $set = $self->name eq 'data' ? undef : $self->name; $oai->_list_records({ set => $set, metadataPrefix => $oai->metadataPrefix }); } sub count { my ($self) = @_; my $oai = $self->store->oai; my $set = $self->name eq 'data' ? undef : $self->name; my $it = $oai->_list_records({ set => $set, metadataPrefix => $oai->metadataPrefix }); my $rec = $it->(); return 0 unless $rec; if ($rec && $rec->{_resumption} && (my $size = $rec->{_resumption}->{completeListSize})) { return $size; } else { my $n = 1; while ($it->()) { $n++; } return $n; } } sub get { my ($self, $id) = @_; my $set = $self->name eq 'data' ? undef : $self->name; my $oai = $self->store->oai; my $rec = $oai->_get_record({ identifier => $id , metadataPrefix => $oai->metadataPrefix })->(); if ($set) { my $sets = $rec->{_setSpec} // []; if (grep(/^$set$/,@$sets)) { return $rec; } else { return undef; } } else { return $rec; } } sub add { my ($self, $data) = @_; Catmandu::NotImplemented->throw("OAI is a read-only store"); } sub delete { my ($self, $id) = @_; Catmandu::NotImplemented->throw("OAI is a read-only store"); } sub delete_all { my ($self) = @_; Catmandu::NotImplemented->throw("OAI is a read-only store"); } sub commit { 1; } 1; __END__ =pod =head1 NAME Catmandu::Store::OAI::Bag - Catmandu::Bag implementation for OAI-PMH =head1 DESCRIPTION This class isn't normally used directly. Instances are constructed using the store's C method. =head1 SEE ALSO L =cut Parser000755000765000024 014662021556 21574 5ustar00hochstenstaff000000000000Catmandu-OAI-0.21/lib/Catmandu/Importer/OAIraw.pm100644000765000024 33614662021556 23045 0ustar00hochstenstaff000000000000Catmandu-OAI-0.21/lib/Catmandu/Importer/OAI/Parserpackage Catmandu::Importer::OAI::Parser::raw; use Catmandu::Sane; use Moo; our $VERSION = '0.21'; sub parse { my ($self,$dom) = @_; return undef unless defined $dom; { _metadata => $dom->toString }; } 1; mods.pm100644000765000024 107514662021556 23237 0ustar00hochstenstaff000000000000Catmandu-OAI-0.21/lib/Catmandu/Importer/OAI/Parserpackage Catmandu::Importer::OAI::Parser::mods; use Catmandu::Sane; use Moo; use MODS::Record; use Catmandu::Util; use JSON; our $VERSION = '0.21'; with 'Catmandu::Logger'; sub parse { my ($self,$dom) = @_; return undef unless defined $dom; my $xml = $dom->toString; my $perl = { error => 1 }; eval { my $mods = MODS::Record->from_xml($xml); $perl = JSON::decode_json($mods->as_json); }; if ($@) { $self->log->error($@); $self->log->error("Failed to parse: $xml"); } { _metadata => $perl }; } 1; oai_dc.pm100644000765000024 56214662021556 23473 0ustar00hochstenstaff000000000000Catmandu-OAI-0.21/lib/Catmandu/Importer/OAI/Parserpackage Catmandu::Importer::OAI::Parser::oai_dc; use Catmandu::Sane; use Moo; our $VERSION = '0.21'; sub parse { my ($self,$dom) = @_; return undef unless defined $dom; my $rec = {}; for ($dom->findnodes("./*")) { my $name = $_->localName; my $value = $_->textContent; push(@{$rec->{$name}}, $value); } $rec; } 1;struct.pm100644000765000024 37514662021556 23603 0ustar00hochstenstaff000000000000Catmandu-OAI-0.21/lib/Catmandu/Importer/OAI/Parserpackage Catmandu::Importer::OAI::Parser::struct; use Catmandu::Sane; use Moo; use XML::Struct qw(readXML); our $VERSION = '0.21'; sub parse { my ($self,$dom) = @_; return undef unless defined $dom; { _metadata => readXML($dom) }; } 1; marcxml.pm100644000765000024 262414662021556 23741 0ustar00hochstenstaff000000000000Catmandu-OAI-0.21/lib/Catmandu/Importer/OAI/Parserpackage Catmandu::Importer::OAI::Parser::marcxml; use Catmandu::Sane; use Moo; our $VERSION = '0.21'; sub parse { my ($self,$dom) = @_; return undef unless defined $dom; my @out; my $id = undef; # Read in the collection tag if available if ($dom->localname eq 'collection') { $dom = $dom->firstChild; } for my $field ($dom->getChildrenByLocalName('*')) { my $name = $field->localname; my $value = $field->textContent // ''; if ($name eq 'leader') { push @out, [ 'LDR', ' ', ' ', '_', $value ]; } elsif ($name eq 'controlfield') { my $tag = $field->getAttribute( 'tag' ); push @out, [ $tag, ' ', ' ', '_', $value ]; $id = $value if $tag eq '001'; } elsif ( $name eq 'datafield' ) { my $tag = $field->getAttribute( 'tag' ); my $ind1 = $field->getAttribute( 'ind1' ) // ' '; my $ind2 = $field->getAttribute( 'ind2' ) // ' '; my @subfield = (); for my $subfield ( $field->getChildrenByLocalName('subfield') ) { my $code = $subfield->getAttribute( 'code' ); my $value = $subfield->textContent; push @subfield, $code, $value; } push @out, [ $tag, $ind1, $ind2, @subfield ]; } } return { _id => $id , record => \@out }; } 1;