From: dbs Date: Wed, 11 Aug 2010 17:47:48 +0000 (+0000) Subject: Bring SRU goodness to OpenILS::WWW::SuperCat X-Git-Url: https://old-git.evergreen-ils.org/?a=commitdiff_plain;h=f59cca4fe623e016337165b27a65181ff2e5dd9a;p=contrib%2FConifer.git Bring SRU goodness to OpenILS::WWW::SuperCat git-svn-id: svn://svn.open-ils.org/ILS-Contrib/conifer/branches/rel_1_6_0@954 6d9bc8c9-1ec2-4278-b937-99fde70a366f --- diff --git a/src/perlmods/OpenILS/WWW/SuperCat.pm b/src/perlmods/OpenILS/WWW/SuperCat.pm index d7ebd3439f..316b8921bc 100644 --- a/src/perlmods/OpenILS/WWW/SuperCat.pm +++ b/src/perlmods/OpenILS/WWW/SuperCat.pm @@ -145,7 +145,7 @@ sub child_init { ->gather(1); $list = [ map { (keys %$_)[0] } @$list ]; - push @$list, 'htmlholdings','html', 'marctxt'; + push @$list, 'htmlholdings','html', 'marctxt', 'ris'; for my $browse_axis ( qw/title author subject topic series item-age/ ) { for my $record_browse_format ( @$list ) { @@ -260,6 +260,7 @@ sub unapi { + FORMATS } elsif ($type eq 'metarecord') { $body .= <<" FORMATS"; @@ -315,6 +316,7 @@ sub unapi { + FORMATS @@ -407,7 +409,7 @@ sub unapi { @{ $supercat->request("open-ils.supercat.$type.formats")->gather(1) } and !grep { $_ eq $base_format } - qw/opac html htmlholdings marctxt/ + qw/opac html htmlholdings marctxt ris/ ) { print "Content-type: text/html; charset=utf-8\n\n"; $apache->custom_response( 406, <<" HTML"); @@ -553,6 +555,10 @@ sub supercat { marctxt text/plain + + + ris + text/plain "; } @@ -622,6 +628,10 @@ sub supercat { marctxt text/plain + + + ris + text/plain "; for my $h (@$list) { @@ -1232,7 +1242,7 @@ sub create_record_feed { $feed->unapi($unapi) if ($flesh); $type = 'atom' if ($type eq 'html'); - $type = 'marcxml' if (($type eq 'htmlholdings') || ($type eq 'marctxt')); + $type = 'marcxml' if (($type eq 'htmlholdings') || ($type eq 'marctxt') || ($type eq 'ris')); #$records = $supercat->request( "open-ils.supercat.record.object.retrieve", $records )->gather(1); @@ -1410,7 +1420,7 @@ our %qualifier_map = ( 'bib.titlealternative' => 'title', 'bib.titleseries' => 'series', 'eg.series' => 'title', - 'eg.identifier' => 'keyword|identifier', + 'eg.identifier' => 'keyword|identifier', # Author/Name class: 'eg.author' => 'author', @@ -1658,7 +1668,7 @@ sub sru_search { 'open-ils.search.biblio.multiclass.query' => {offset => $offset, limit => $limit} => $search_string => 1 )->gather(1); - my $bre = $supercat->request( 'open-ils.supercat.record.object.retrieve' => [ map { $_->[0] } @{$recs->{ids}} ] )->gather(1); + my $bre = $supercat->request( 'open-ils.supercat.record.object.retrieve' => [ map { $_->[0] } @{$recs->{ids}} ] )->gather(1); foreach my $record (@$bre) { my $marcxml = $record->marc; @@ -1669,6 +1679,13 @@ sub sru_search { my $bib_holdings = $supercat->request('open-ils.supercat.record.basic_holdings.retrieve', $record->id, $shortname || '-')->gather(1); my $marc = MARC::Record->new_from_xml($marcxml, 'UTF8', 'XML'); + # Force record leader to 'a' as our data is always UTF8 + # Avoids marc8_to_utf8 from being invoked with horrible results + # on the off-chance the record leader isn't correct + my $ldr = $marc->leader; + substr($ldr, 9, 1, 'a'); + $marc->leader($ldr); + # Expects the record ID in the 001 $marc->delete_field($_) for ($marc->field('001')); if (!$marc->field('001')) { @@ -1703,7 +1720,8 @@ sub sru_search { ) ); - $marcxml = $marc->as_xml_record(); + # Ensure the data is encoded as UTF8 before we hand it off + $marcxml = encode_utf8($marc->as_xml_record()); $marcxml =~ s/^<\?xml version="1.0" encoding="UTF-8"\?>//o; } @@ -1716,9 +1734,9 @@ sub sru_search { ); } - $resp->numberOfRecords($recs->{count}); + $resp->numberOfRecords($recs->{count}); - } elsif ( $resp->type eq 'explain' ) { + } elsif ( $resp->type eq 'explain' ) { if (!$ex_doc) { my $host = $cgi->virtual_host || $cgi->server_name; @@ -1783,9 +1801,9 @@ sub sru_search { ); } - print $cgi->header( -type => 'application/xml' ); - print $U->entityize($resp->asXML) . "\n"; - return Apache2::Const::OK; + print $cgi->header( -type => 'application/xml' ); + print $U->entityize($resp->asXML) . "\n"; + return Apache2::Const::OK; }