1 package OpenILS::WWW::SuperCat;
2 use strict; use warnings;
6 use Apache2::Const -compile => qw(OK REDIRECT DECLINED :log);
7 use APR::Const -compile => qw(:error SUCCESS);
8 use Apache2::RequestRec ();
9 use Apache2::RequestIO ();
10 use Apache2::RequestUtil;
14 use OpenSRF::EX qw(:try);
16 use OpenSRF::AppSession;
19 use OpenILS::Utils::Fieldmapper;
22 # set the bootstrap config when this module is loaded
23 my ($bootstrap, $supercat);
32 OpenSRF::System->bootstrap_client( config_file => $bootstrap );
33 $supercat = OpenSRF::AppSession->create('open-ils.supercat');
39 return Apache2::Const::DECLINED if (-e $apache->filename);
41 my $path = $apache->path_info;
43 my ($id,$type,$format,$command) = reverse split '/', $path;
45 print "Content-type: text/xml; charset=utf-8\n\n";
47 if ( $path =~ m{^/?$}o ) {
50 my $uri = $cgi->param('uri') || '';
52 $format = $cgi->param('format');
53 ($id,$type) = ('','');
56 if ($uri =~ m{^oils:/([^\/]+)/(\d+)}o) {
59 $type = 'metarecord' if ($1 =~ /^m/o);
62 ->request("open-ils.supercat.$type.formats")
68 "<format><name>$_</name><type>text/xml</type></format>"
74 ->request("open-ils.supercat.record.formats")
78 ->request("open-ils.supercat.metarecord.formats")
82 my %hash = map { ($_ => $_) } @$list;
83 $list = [ sort keys %hash ];
88 "<format><name>$_</name><type>text/xml</type></format>"
91 return Apache2::Const::OK;
96 if ($uri =~ m{^oils:/([^\/]+)/(\d+)}o) {
99 $type = 'metarecord' if ($1 =~ /^m/o);
100 $command = 'retrieve';
103 } elsif ( $path =~ m{^/formats/([^\/]+)$}o ) {
105 ->request("open-ils.supercat.$1.formats")
111 "<format><name>$_</name><type>text/xml</type></format>"
114 return Apache2::Const::OK;
118 ->request("open-ils.supercat.$type.$format.$command",$id)
121 return Apache2::Const::OK;