From f0ac3dab0206e5fafca8ed1d1cb491f8f2034406 Mon Sep 17 00:00:00 2001 From: Galen Charlton Date: Tue, 16 Feb 2016 11:31:34 -0500 Subject: [PATCH] LP#1367926: various improvements and bugfixes - use entityize() so that non-ASCII characters don't break XML well-formedness - when a U2 identifier is given, the list of supported formats returned is now accurate - biblio_record_entry_feed now works; for example, /opac/extras/unapi?id=tag::U2@biblio_record_entry_feed/1608,454{holdings_xml}&format=mods32 returns a modsCollection of bibs 1608 and 454. Signed-off-by: Galen Charlton Signed-off-by: Kathy Lussier --- .../lib/OpenILS/Application/SuperCat.pm | 24 +++++----- .../src/perlmods/lib/OpenILS/WWW/SuperCat.pm | 44 ++++++++++++++++--- 2 files changed, 53 insertions(+), 15 deletions(-) diff --git a/Open-ILS/src/perlmods/lib/OpenILS/Application/SuperCat.pm b/Open-ILS/src/perlmods/lib/OpenILS/Application/SuperCat.pm index 26f23725ea..3a8aebee7d 100644 --- a/Open-ILS/src/perlmods/lib/OpenILS/Application/SuperCat.pm +++ b/Open-ILS/src/perlmods/lib/OpenILS/Application/SuperCat.pm @@ -748,18 +748,22 @@ sub u2 { $u2->id( $copy->id ); } + if ($u2->classname eq 'biblio_record_entry_feed') { + $u2->id( '{' . $u2->id . '}' ); + } + my $args = [ + 'unapi.' . $u2->classname, + $u2->id, + $format, + ]; + push @$args, $u2->classname unless $u2->classname eq 'biblio_record_entry_feed'; + push @$args, '{' . ( $u2->includes ? join( ',', keys %{ $u2->includes } ) : '' ) . '}'; + push @$args, ($u2->location || undef); + push @$args, ($u2->depth || undef); + return OpenSRF::AppSession->create('open-ils.cstore')->request( "open-ils.cstore.json_query.atomic", - { from => - [ 'unapi.' . $u2->classname, - $u2->id, - $format, - $u2->classname, - '{' . ( $u2->includes ? join( ',', keys %{ $u2->includes } ) : '' ) . '}', - $u2->location || undef, - $u2->depth || undef - ] - } + { from => $args } )->gather(1)->[0]{'unapi.'. $u2->classname}; } __PACKAGE__->register_method( diff --git a/Open-ILS/src/perlmods/lib/OpenILS/WWW/SuperCat.pm b/Open-ILS/src/perlmods/lib/OpenILS/WWW/SuperCat.pm index 83274aca48..06e43e11a4 100644 --- a/Open-ILS/src/perlmods/lib/OpenILS/WWW/SuperCat.pm +++ b/Open-ILS/src/perlmods/lib/OpenILS/WWW/SuperCat.pm @@ -458,9 +458,39 @@ sub unapi2 { print "Content-type: $ctype; charset=utf-8\n\n"; print "\n"; - print $supercat - ->request("open-ils.supercat.u2", $u2->toURI, $format) - ->gather(1); + print $U->entityize( + $supercat->request("open-ils.supercat.u2", $u2->toURI, $format) + ->gather(1) + ); + + return Apache2::Const::OK; +} + +sub unapi2_formats { + my $apache = shift; + my $u2 = shift; + + print "Content-type: application/xml; charset=utf-8\n\n"; + print "\n"; + my $id = $u2->toURI; + if ($u2->classname =~ /^(?:bre|biblio_record_entry_feed)$/) { + # TODO: if/when unapi.bre_output_layout becomes something + # that actually changes, the hard-coding here should be + # replaced + print < + + + + +FORMATS + } else { + print < + + +FORMATS + } return Apache2::Const::OK; } @@ -490,8 +520,12 @@ sub unapi { my $format = $cgi->param('format') || ''; (my $base_format = $format) =~ s/(-full|-uris)$//o; my $u2uri = OpenILS::Utils::TagURI->new($uri); - if ($format and $u2uri->version > 1) { - return unapi2($apache, $u2uri, $format); + if ($u2uri->version > 1) { + if ($format) { + return unapi2($apache, $u2uri, $format); + } else { + return unapi2_formats($apache, $u2uri); + } } my $host = $cgi->virtual_host || $cgi->server_name; -- 2.43.2