1 package OpenILS::Application::Cat::AuthCommon;
2 use strict; use warnings;
3 use OpenILS::Utils::CStoreEditor q/:funcs/;
4 use OpenSRF::Utils::Logger qw($logger);
5 use OpenILS::Application::AppUtils;
6 use OpenILS::Utils::Fieldmapper;
7 use OpenILS::Const qw/:const/;
8 use OpenSRF::AppSession;
10 my $U = 'OpenILS::Application::AppUtils';
11 my $MARC_NAMESPACE = 'http://www.loc.gov/MARC21/slim';
14 # ---------------------------------------------------------------------------
15 # Shared authority mangling code. Do not publish methods from here.
16 # ---------------------------------------------------------------------------
18 # generate a MARC XML document from a MARC XML string
21 my $marc_doc = XML::LibXML->new->parse_string($xml);
22 $marc_doc->documentElement->setNamespace($MARC_NAMESPACE, 'marc', 1);
23 $marc_doc->documentElement->setNamespace($MARC_NAMESPACE);
28 sub import_authority_record {
29 my($class, $e, $marc_xml, $source) = @_;
31 my $marc_doc = marc_xml_to_doc($marc_xml);
32 my $rec = Fieldmapper::authority::record_entry->new;
33 $rec->creator($e->requestor->id);
34 $rec->editor($e->requestor->id);
35 $rec->create_date('now');
36 $rec->edit_date('now');
37 $rec->marc($U->entityize($marc_doc->documentElement->toString));
39 $rec = $e->create_authority_record_entry($rec) or return $e->die_event;
41 # we don't care about the result, just fire off the request
42 #my $ses = OpenSRF::AppSession->create('open-ils.ingest');
43 #$ses->request('open-ils.ingest.full.authority.record', $recid);
49 sub overlay_authority_record {
50 my($class, $e, $rec_id, $marc_xml, $source) = @_;
52 my $marc_doc = marc_xml_to_doc($marc_xml);
53 my $rec = $e->retrieve_authority_record_entry($rec_id) or return $e->die_event;
54 $rec->editor($e->requestor->id);
55 $rec->edit_date('now');
56 $rec->marc($U->entityize($marc_doc->documentElement->toString));
58 $rec = $e->update_authority_record_entry($rec) or return $e->die_event;
60 # we don't care about the result, just fire off the request
61 #my $ses = OpenSRF::AppSession->create('open-ils.ingest');
62 #$ses->request('open-ils.ingest.full.authority.record', $recid);