use OpenILS::Utils::Fieldmapper;
use OpenILS::Utils::CStoreEditor q/:funcs/;
+use OpenILS::Utils::TagURI;
our (
}
);
+sub u2 {
+ my $self = shift;
+ my $client = shift;
+
+ my $u2 = shift;
+ my $format = shift || 'xml';
+
+ $u2 = OpenILS::Utils::TagURI->new($u2);
+ return '' unless $u2;
+
+ # Use pathinfo on acp as a lookup type specifier.
+ if ($u2->classname eq 'acp' and $u2->pathinfo =~ /\bbarcode\b/) {
+ my( $copy, $evt ) = $U->fetch_copy_by_barcode( $u2->id );
+ $u2->id( $copy->id );
+ }
+
+ 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
+ ]
+ }
+ )->gather(1)->[0]{'unapi.'. $u2->classname};
+}
+__PACKAGE__->register_method(
+ method => 'u2',
+ api_name => 'open-ils.supercat.u2',
+ api_level => 1,
+ argc => 2,
+ signature =>
+ { desc => <<" DESC",
+Returns the XML representation of the requested object
+ DESC
+ params =>
+ [
+ { name => 'u2',
+ desc => 'The U2 Tag URI (OpenILS::Utils::TagURI)',
+ type => 'object' },
+ { name => 'format',
+ desc => 'For bre and bre feeds, the xml transform format',
+ type => 'string' }
+ ],
+ 'return' =>
+ { desc => 'XML (or transformed) object data',
+ type => 'string' }
+ }
+);
+
sub general_browse {
my $self = shift;
$self->classname($classname);
$self->id($id);
- $self->paging(($paging ? [ map { s/^\s*//; s/\s*$//; $_ } split(',', $paging) ] : []));
- $self->includes(($inc ? { map { /:/ ? split(':') : ($_,undef) } map { s/^\s*//; s/\s*$//; $_ } split(',', $inc) } : {}));
+ $self->paging(($paging ? [ map { s/^\s*//; s/\s*$//; $_ } split(',', $paging) ] : undef));
+ $self->includes(($inc ? { map { /:/ ? split(':') : ($_,undef) } map { s/^\s*//; s/\s*$//; $_ } split(',', $inc) } : undef));
$self->location($loc);
$self->depth($depth);
$self->pathinfo($mods);
$tag .= 'U2@' if ($self->version == 2);
$tag .= $self->classname . '/' . $self->id;
$tag .= '['. join(',', @{ $self->paging }) . ']' if defined($self->paging);
- $tag .= '{'. join(',', map { $_ . ':' . $self->includes->{$_} } keys %{ $self->includes }) . '}' if defined($self->includes);
+ $tag .= '{'. join(',', map { $self->includes->{$_} ? ($_ . ':' . $self->includes->{$_}) : ($_) } keys %{ $self->includes }) . '}' if defined($self->includes);
$tag .= '/' . $self->location if defined($self->location);
$tag .= '/' . $self->depth if defined($self->depth);
$tag .= '/' . $self->pathinfo if defined($self->pathinfo);
use OpenILS::WWW::SuperCat::Feed;
use OpenSRF::Utils::Logger qw/$logger/;
use OpenILS::Application::AppUtils;
+use OpenILS::Utils::TagURI;
use MARC::Record;
use MARC::File::XML ( BinaryEncoding => 'UTF-8' );
return Apache2::Const::OK;
}
+sub unapi2 {
+ my $apache = shift;
+ my $u2 = shift;
+ my $format = shift;
+
+ my $ctype = 'application/xml';
+ # Only bre and biblio_record_entry_feed have tranforms, but we'll ignore that for now
+ if ($u2->classname =~ /^(?:bre|biblio_record_entry_feed)$/ and $format ne 'xml') {
+ # XXX set $ctype to something else
+ }
+
+ print "Content-type: $ctype; charset=utf-8\n\n";
+ print "<?xml version='1.0' encoding='UTF-8' ?>\n";
+ print $supercat
+ ->request("open-ils.supercat.u2", $u2->toURI, $format)
+ ->gather(1);
+
+ return Apache2::Const::OK;
+}
+
sub unapi {
my $apache = shift;
my $uri = $cgi->param('id') || '';
+
+ 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);
+ }
+
my $host = $cgi->virtual_host || $cgi->server_name;
my $skin = $cgi->param('skin') || 'default';
# Enable localized results of copy status, etc
$supercat->session_locale($locale);
- my $format = $cgi->param('format') || '';
my $flesh_feed = parse_feed_type($format);
(my $base_format = $format) =~ s/(-full|-uris)$//o;
my ($id,$type,$command,$lib,$depth,$paging) = ('','record','');